You've already forked agentic-coding-workflow
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package chat
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type usageService struct{ repo Repository }
|
|
|
|
var _ UsageService = (*usageService)(nil)
|
|
|
|
// NewUsageService 构造 llm_usage 写入与汇总查询服务。
|
|
func NewUsageService(repo Repository) UsageService { return &usageService{repo: repo} }
|
|
|
|
func (s *usageService) Insert(ctx context.Context, in UsageRecord) error {
|
|
return s.repo.InsertUsage(ctx, in)
|
|
}
|
|
|
|
func (s *usageService) SummarizeByUser(ctx context.Context, from, to time.Time) ([]UserUsageRow, error) {
|
|
return s.repo.SummarizeUsageByUser(ctx, from, to)
|
|
}
|
|
|
|
func (s *usageService) SummarizeByModel(ctx context.Context, from, to time.Time) ([]ModelUsageRow, error) {
|
|
return s.repo.SummarizeUsageByModel(ctx, from, to)
|
|
}
|
|
|
|
func (s *usageService) SummarizeByDay(ctx context.Context, from, to time.Time) ([]DayUsageRow, error) {
|
|
return s.repo.SummarizeUsageByDay(ctx, from, to)
|
|
}
|
|
|
|
func (s *usageService) UserDaily(ctx context.Context, userID uuid.UUID, from, to time.Time) ([]DayUsageRow, error) {
|
|
return s.repo.SummarizeUserDaily(ctx, userID, from, to)
|
|
}
|