@@ -1690,6 +1690,20 @@ func (*FakeQuerier) DeleteOldNotificationMessages(_ context.Context) error {
1690
1690
return nil
1691
1691
}
1692
1692
1693
+ func (q * FakeQuerier ) DeleteOldNotificationReportGeneratorLogs (_ context.Context , params database.DeleteOldNotificationReportGeneratorLogsParams ) error {
1694
+ q .mutex .Lock ()
1695
+ defer q .mutex .Unlock ()
1696
+
1697
+ var validLogs []database.ReportGeneratorLog
1698
+ for _ , record := range q .reportGeneratorLogs {
1699
+ if record .NotificationTemplateID != params .NotificationTemplateID || record .LastGeneratedAt .After (params .Before ) {
1700
+ validLogs = append (validLogs , record )
1701
+ }
1702
+ }
1703
+ q .reportGeneratorLogs = validLogs
1704
+ return nil
1705
+ }
1706
+
1693
1707
func (q * FakeQuerier ) DeleteOldProvisionerDaemons (_ context.Context ) error {
1694
1708
q .mutex .Lock ()
1695
1709
defer q .mutex .Unlock ()
@@ -1709,20 +1723,6 @@ func (q *FakeQuerier) DeleteOldProvisionerDaemons(_ context.Context) error {
1709
1723
return nil
1710
1724
}
1711
1725
1712
- func (q * FakeQuerier ) DeleteOldNotificationReportGeneratorLogs (_ context.Context , params database.DeleteOldNotificationReportGeneratorLogsParams ) error {
1713
- q .mutex .Lock ()
1714
- defer q .mutex .Unlock ()
1715
-
1716
- var validLogs []database.ReportGeneratorLog
1717
- for _ , record := range q .reportGeneratorLogs {
1718
- if record .NotificationTemplateID != params .NotificationTemplateID || record .LastGeneratedAt .After (params .Before ) {
1719
- validLogs = append (validLogs , record )
1720
- }
1721
- }
1722
- q .reportGeneratorLogs = validLogs
1723
- return nil
1724
- }
1725
-
1726
1726
func (q * FakeQuerier ) DeleteOldWorkspaceAgentLogs (_ context.Context , threshold time.Time ) error {
1727
1727
q .mutex .Lock ()
1728
1728
defer q .mutex .Unlock ()
@@ -3002,6 +3002,23 @@ func (q *FakeQuerier) GetNotificationMessagesByStatus(_ context.Context, arg dat
3002
3002
return out , nil
3003
3003
}
3004
3004
3005
+ func (q * FakeQuerier ) GetNotificationReportGeneratorLogByUserAndTemplate (_ context.Context , arg database.GetNotificationReportGeneratorLogByUserAndTemplateParams ) (database.ReportGeneratorLog , error ) {
3006
+ err := validateDatabaseType (arg )
3007
+ if err != nil {
3008
+ return database.ReportGeneratorLog {}, err
3009
+ }
3010
+
3011
+ q .mutex .RLock ()
3012
+ defer q .mutex .RUnlock ()
3013
+
3014
+ for _ , record := range q .reportGeneratorLogs {
3015
+ if record .UserID == arg .UserID && record .NotificationTemplateID == arg .NotificationTemplateID {
3016
+ return record , nil
3017
+ }
3018
+ }
3019
+ return database.ReportGeneratorLog {}, sql .ErrNoRows
3020
+ }
3021
+
3005
3022
func (* FakeQuerier ) GetNotificationTemplateByID (_ context.Context , _ uuid.UUID ) (database.NotificationTemplate , error ) {
3006
3023
// Not implementing this function because it relies on state in the database which is created with migrations.
3007
3024
// We could consider using code-generation to align the database state and dbmem, but it's not worth it right now.
@@ -3603,23 +3620,6 @@ func (q *FakeQuerier) GetReplicasUpdatedAfter(_ context.Context, updatedAt time.
3603
3620
return replicas , nil
3604
3621
}
3605
3622
3606
- func (q * FakeQuerier ) GetNotificationReportGeneratorLogByUserAndTemplate (_ context.Context , arg database.GetNotificationReportGeneratorLogByUserAndTemplateParams ) (database.ReportGeneratorLog , error ) {
3607
- err := validateDatabaseType (arg )
3608
- if err != nil {
3609
- return database.ReportGeneratorLog {}, err
3610
- }
3611
-
3612
- q .mutex .RLock ()
3613
- defer q .mutex .RUnlock ()
3614
-
3615
- for _ , record := range q .reportGeneratorLogs {
3616
- if record .UserID == arg .UserID && record .NotificationTemplateID == arg .NotificationTemplateID {
3617
- return record , nil
3618
- }
3619
- }
3620
- return database.ReportGeneratorLog {}, sql .ErrNoRows
3621
- }
3622
-
3623
3623
func (q * FakeQuerier ) GetRuntimeConfig (_ context.Context , key string ) (string , error ) {
3624
3624
q .mutex .Lock ()
3625
3625
defer q .mutex .Unlock ()
@@ -9374,6 +9374,26 @@ func (q *FakeQuerier) UpsertLogoURL(_ context.Context, data string) error {
9374
9374
return nil
9375
9375
}
9376
9376
9377
+ func (q * FakeQuerier ) UpsertNotificationReportGeneratorLog (_ context.Context , arg database.UpsertNotificationReportGeneratorLogParams ) error {
9378
+ err := validateDatabaseType (arg )
9379
+ if err != nil {
9380
+ return err
9381
+ }
9382
+
9383
+ q .mutex .Lock ()
9384
+ defer q .mutex .Unlock ()
9385
+
9386
+ for i , record := range q .reportGeneratorLogs {
9387
+ if arg .NotificationTemplateID == record .NotificationTemplateID && arg .UserID == record .UserID {
9388
+ q .reportGeneratorLogs [i ].LastGeneratedAt = arg .LastGeneratedAt
9389
+ return nil
9390
+ }
9391
+ }
9392
+
9393
+ q .reportGeneratorLogs = append (q .reportGeneratorLogs , database .ReportGeneratorLog (arg ))
9394
+ return nil
9395
+ }
9396
+
9377
9397
func (q * FakeQuerier ) UpsertNotificationsSettings (_ context.Context , data string ) error {
9378
9398
q .mutex .Lock ()
9379
9399
defer q .mutex .Unlock ()
@@ -9429,26 +9449,6 @@ func (q *FakeQuerier) UpsertProvisionerDaemon(_ context.Context, arg database.Up
9429
9449
return d , nil
9430
9450
}
9431
9451
9432
- func (q * FakeQuerier ) UpsertNotificationReportGeneratorLog (_ context.Context , arg database.UpsertNotificationReportGeneratorLogParams ) error {
9433
- err := validateDatabaseType (arg )
9434
- if err != nil {
9435
- return err
9436
- }
9437
-
9438
- q .mutex .Lock ()
9439
- defer q .mutex .Unlock ()
9440
-
9441
- for i , record := range q .reportGeneratorLogs {
9442
- if arg .NotificationTemplateID == record .NotificationTemplateID && arg .UserID == record .UserID {
9443
- q .reportGeneratorLogs [i ].LastGeneratedAt = arg .LastGeneratedAt
9444
- return nil
9445
- }
9446
- }
9447
-
9448
- q .reportGeneratorLogs = append (q .reportGeneratorLogs , database .ReportGeneratorLog (arg ))
9449
- return nil
9450
- }
9451
-
9452
9452
func (q * FakeQuerier ) UpsertRuntimeConfig (_ context.Context , arg database.UpsertRuntimeConfigParams ) error {
9453
9453
err := validateDatabaseType (arg )
9454
9454
if err != nil {
0 commit comments