fix: filter monthly reports by month range
This commit is contained in:
@@ -935,10 +935,18 @@ func (s *Store) DailyReportStats(ctx context.Context, date time.Time, department
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func (s *Store) MonthlyReports(ctx context.Context, userID int64, cursor string, limit int) ([]MonthlyReport, string, error) {
|
||||
func (s *Store) MonthlyReports(ctx context.Context, userID int64, fromMonth, toMonth, cursor string, limit int) ([]MonthlyReport, string, error) {
|
||||
var items []MonthlyReport
|
||||
query := `SELECT report_id,author_id,report_month,work_summary,next_plan,attachments,status,read_state,version,submitted_at,created_at,updated_at FROM im_monthly_reports WHERE tenant_id=? AND author_id=?`
|
||||
args := []any{s.tenant(), userID}
|
||||
if fromMonth != "" {
|
||||
query += ` AND report_month>=?`
|
||||
args = append(args, fromMonth)
|
||||
}
|
||||
if toMonth != "" {
|
||||
query += ` AND report_month<=?`
|
||||
args = append(args, toMonth)
|
||||
}
|
||||
if cursor != "" {
|
||||
query += ` AND report_id>?`
|
||||
args = append(args, cursor)
|
||||
|
||||
Reference in New Issue
Block a user