feat: user usage

This commit is contained in:
Zack Fu Zi Xiang 2024-03-14 02:27:59 +08:00
parent af32cd62d0
commit f7a8cdcd65
No known key found for this signature in database
2 changed files with 10 additions and 14 deletions

View File

@ -30,7 +30,7 @@ pub async fn get_user_workspace_limit(
let res = resp.json::<JsonResponse<UserUsageLimit>>().await?;
let b = res.data;
let c = b.workspace_count.unwrap_or({
tracing::warn!("workspace_count is None, return 0");
tracing::warn!("workspace_count is None, returning 0");
0
});
Ok(c as u32)

View File

@ -90,8 +90,6 @@ pub async fn admin_navigate_handler() -> Result<Html<String>, WebAppError> {
}
pub async fn user_invite_handler() -> Result<Html<String>, WebAppError> {
println!("----- user_invite_handler");
render_template(templates::Invite)
}
@ -99,8 +97,6 @@ pub async fn user_usage_handler(
State(state): State<AppState>,
session: UserSession,
) -> Result<Html<String>, WebAppError> {
println!("----- user_usage_handler");
let workspace_count =
get_user_workspace_count(&session.token.access_token, &state.appflowy_cloud_url)
.await
@ -113,16 +109,16 @@ pub async fn user_usage_handler(
&session.token.access_token,
&state.appflowy_cloud_gateway_url,
)
.await;
println!("workspace count: {:?}", workspace_count);
.await
.unwrap_or_else(|err| {
tracing::error!("Error getting user workspace limit: {:?}", err);
0
});
render_template(templates::Invite)
// todo!();
// render_template(templates::UserUsage {
// workspace_count: 500,
// workspace_limit: 1000,
// })
render_template(templates::UserUsage {
workspace_count,
workspace_limit,
})
}
pub async fn workspace_usage_handler(session: UserSession) -> Result<Html<String>, WebAppError> {