feat: user usage
This commit is contained in:
parent
af32cd62d0
commit
f7a8cdcd65
|
|
@ -30,7 +30,7 @@ pub async fn get_user_workspace_limit(
|
||||||
let res = resp.json::<JsonResponse<UserUsageLimit>>().await?;
|
let res = resp.json::<JsonResponse<UserUsageLimit>>().await?;
|
||||||
let b = res.data;
|
let b = res.data;
|
||||||
let c = b.workspace_count.unwrap_or({
|
let c = b.workspace_count.unwrap_or({
|
||||||
tracing::warn!("workspace_count is None, return 0");
|
tracing::warn!("workspace_count is None, returning 0");
|
||||||
0
|
0
|
||||||
});
|
});
|
||||||
Ok(c as u32)
|
Ok(c as u32)
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,6 @@ pub async fn admin_navigate_handler() -> Result<Html<String>, WebAppError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn user_invite_handler() -> Result<Html<String>, WebAppError> {
|
pub async fn user_invite_handler() -> Result<Html<String>, WebAppError> {
|
||||||
println!("----- user_invite_handler");
|
|
||||||
|
|
||||||
render_template(templates::Invite)
|
render_template(templates::Invite)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,8 +97,6 @@ pub async fn user_usage_handler(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
session: UserSession,
|
session: UserSession,
|
||||||
) -> Result<Html<String>, WebAppError> {
|
) -> Result<Html<String>, WebAppError> {
|
||||||
println!("----- user_usage_handler");
|
|
||||||
|
|
||||||
let workspace_count =
|
let workspace_count =
|
||||||
get_user_workspace_count(&session.token.access_token, &state.appflowy_cloud_url)
|
get_user_workspace_count(&session.token.access_token, &state.appflowy_cloud_url)
|
||||||
.await
|
.await
|
||||||
|
|
@ -113,16 +109,16 @@ pub async fn user_usage_handler(
|
||||||
&session.token.access_token,
|
&session.token.access_token,
|
||||||
&state.appflowy_cloud_gateway_url,
|
&state.appflowy_cloud_gateway_url,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
println!("workspace count: {:?}", workspace_count);
|
.unwrap_or_else(|err| {
|
||||||
|
tracing::error!("Error getting user workspace limit: {:?}", err);
|
||||||
|
0
|
||||||
|
});
|
||||||
|
|
||||||
render_template(templates::Invite)
|
render_template(templates::UserUsage {
|
||||||
|
workspace_count,
|
||||||
// todo!();
|
workspace_limit,
|
||||||
// render_template(templates::UserUsage {
|
})
|
||||||
// workspace_count: 500,
|
|
||||||
// workspace_limit: 1000,
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn workspace_usage_handler(session: UserSession) -> Result<Html<String>, WebAppError> {
|
pub async fn workspace_usage_handler(session: UserSession) -> Result<Html<String>, WebAppError> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue