Skip to content

Commit cc20391

Browse files
authored
feat: make billing cycle optional in usage response (#2054)
1 parent 30bb74a commit cc20391

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

common/src/models/user.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,29 @@ pub struct UpdateAccountTierRequest {
224224
pub account_tier: AccountTier,
225225
}
226226

227-
/// Response for the /user/me/usage backend endpoint
227+
/// Sub-Response for the /user/me/usage backend endpoint
228228
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
229229
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
230230
#[typeshare::typeshare]
231-
pub struct UserUsageResponse {
231+
pub struct UserBillingCycle {
232232
/// Billing cycle start, or monthly from user creation
233233
/// depending on the account tier
234234
pub start: NaiveDate,
235235

236236
/// Billing cycle end, or end of month from user creation
237237
/// depending on the account tier
238238
pub end: NaiveDate,
239+
}
240+
241+
/// Response for the /user/me/usage backend endpoint
242+
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
243+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244+
#[typeshare::typeshare]
245+
pub struct UserUsageResponse {
246+
/// Billing cycle for user, will be None if no usage data exists for user.
247+
pub billing_cycle: Option<UserBillingCycle>,
239248

240-
/// HashMap of project related metrics for this cycle
241-
/// keyed by project_id
249+
/// HashMap of project related metrics for this cycle keyed by project_id. Will be empty
250+
/// if no project usage data exists for user.
242251
pub projects: HashMap<String, ProjectUsageResponse>,
243252
}

common/types.ts

Lines changed: 18 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)