feat(reports): derive analytics aggregates

This commit is contained in:
2026-06-05 20:53:30 +08:00
parent 37bdac422a
commit a48b9cda8e
8 changed files with 726 additions and 72 deletions
+8 -1
View File
@@ -17,6 +17,13 @@ func NewReportingEventRepo(db *gorm.DB) *ReportingEventRepo {
return &ReportingEventRepo{db: db}
}
func (r *ReportingEventRepo) DB() *gorm.DB {
if r == nil {
return nil
}
return r.db
}
func (r *ReportingEventRepo) Create(ctx context.Context, event *model.ReportingEvent) error {
return r.db.WithContext(ctx).Create(event).Error
}
@@ -75,4 +82,4 @@ func (r *ReportingEventRepo) FindByAccountIDAndTimeRange(ctx context.Context, ac
Where("account_id = ? AND event_start_time >= ? AND event_end_time <= ?", accountID, since, until).
Find(&events).Error
return events, err
}
}
@@ -17,6 +17,13 @@ func NewReportingEventsRollupRepo(db *gorm.DB) *ReportingEventsRollupRepo {
return &ReportingEventsRollupRepo{db: db}
}
func (r *ReportingEventsRollupRepo) DB() *gorm.DB {
if r == nil {
return nil
}
return r.db
}
func (r *ReportingEventsRollupRepo) Create(ctx context.Context, rollup *model.ReportingEventsRollup) error {
return r.db.WithContext(ctx).Create(rollup).Error
}
@@ -82,4 +89,4 @@ func (r *ReportingEventsRollupRepo) FindByAccountAndDateRangeWithDimension(ctx c
}
err := query.Find(&rollups).Error
return rollups, err
}
}