collab: Add GET /billing/usage endpoint (#28832)

This PR adds a `GET /billing/usage` endpoint for retrieving billing
usage to show on the `zed.dev/account` page.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-04-15 23:28:09 -04:00 committed by GitHub
parent 222d4a2546
commit b486e32f05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 148 additions and 7 deletions

View file

@ -19,6 +19,18 @@ pub struct Model {
pub created_at: DateTime,
}
impl Model {
pub fn current_period_start_at(&self) -> Option<DateTimeUtc> {
let period_start = self.stripe_current_period_start?;
chrono::DateTime::from_timestamp(period_start, 0)
}
pub fn current_period_end_at(&self) -> Option<DateTimeUtc> {
let period_end = self.stripe_current_period_end?;
chrono::DateTime::from_timestamp(period_end, 0)
}
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(