pub struct TokenUsageModel {}Implementations§
Source§impl TokenUsageModel
impl TokenUsageModel
Sourcepub async fn list_by_user(
&self,
pool: &Pool<Postgres>,
user_id: i64,
page: u64,
limit: u64,
) -> Result<Vec<TokenUsage>, Error>
pub async fn list_by_user( &self, pool: &Pool<Postgres>, user_id: i64, page: u64, limit: u64, ) -> Result<Vec<TokenUsage>, Error>
按用户 ID 查询消耗记录(分页,倒序)。
Sourcepub async fn summary_by_service(
&self,
pool: &Pool<Postgres>,
user_id: Option<i64>,
) -> Result<Vec<TokenUsageSummary>, Error>
pub async fn summary_by_service( &self, pool: &Pool<Postgres>, user_id: Option<i64>, ) -> Result<Vec<TokenUsageSummary>, Error>
按服务+模型维度聚合消耗汇总(用于统计分析)。
Trait Implementations§
Source§impl Default for TokenUsageModel
impl Default for TokenUsageModel
Source§fn default() -> TokenUsageModel
fn default() -> TokenUsageModel
Returns the “default value” for a type. Read more
Source§impl Model for TokenUsageModel
impl Model for TokenUsageModel
type Output = TokenUsage
fn new() -> Self
async fn schema_view(&self, _pool: &Pool<Postgres>) -> SchemaView
async fn insert(&self, pool: &Pool<Postgres>, data: Value) -> Result<u64, Error>
async fn get_by_id( &self, pool: &Pool<Postgres>, id: u64, ) -> Result<Option<Self::Output>, Error>
async fn delete_by_id( &self, pool: &Pool<Postgres>, id: u64, ) -> Result<(), Error>
async fn count( &self, pool: &Pool<Postgres>, params: &ModelListParams, ) -> Result<i64, Error>
async fn list( &self, pool: &Pool<Postgres>, params: &ModelListParams, ) -> Result<Vec<Self::Output>, Error>
fn push_filter_conditions<'args>( &self, qb: &mut QueryBuilder<'args, Postgres>, filters: &HashMap<String, String>, ) -> Result<(), Error>
fn keyword(&self) -> String
fn push_conditions<'args>( &self, qb: &mut QueryBuilder<'args, Postgres>, params: &ModelListParams, ) -> Result<(), Error>
fn update_by_id<'a>( &'a self, _pool: &'a Pool<Postgres>, _id: u64, _params: Value, ) -> impl Future<Output = Result<(), Error>> + Send + 'a
fn list_and_count<'a>( &'a self, pool: &'a Pool<Postgres>, count: bool, params: &'a ModelListParams, ) -> impl Future<Output = Result<Value, Error>> + Send + 'a
fn search_options<'a>( &'a self, _pool: &'a Pool<Postgres>, _keyword: Option<String>, ) -> impl Future<Output = Result<Vec<SchemaOption>, Error>> + Send + 'a
Auto Trait Implementations§
impl Freeze for TokenUsageModel
impl RefUnwindSafe for TokenUsageModel
impl Send for TokenUsageModel
impl Sync for TokenUsageModel
impl Unpin for TokenUsageModel
impl UnsafeUnpin for TokenUsageModel
impl UnwindSafe for TokenUsageModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more