Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7a88e0

Browse files
committed
fmt and lint
1 parentb60d525 commita7a88e0

File tree

2 files changed

+96
-30
lines changed

2 files changed

+96
-30
lines changed

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3588,16 +3588,17 @@ func (q *querier) RevokeDBCryptKey(ctx context.Context, activeKeyDigest string)
35883588
returnq.db.RevokeDBCryptKey(ctx,activeKeyDigest)
35893589
}
35903590

3591-
func (q*querier)SetInboxNotificationAsRead(ctx context.Context,arg database.SetInboxNotificationAsReadParams)error {
3592-
fetchFunc:=func(ctx context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
3593-
returnq.db.GetInboxNotificationByID(ctx,id)
3594-
}
3591+
func (*querier)SetInboxNotificationAsRead(_ context.Context,_ database.SetInboxNotificationAsReadParams)error {
3592+
panic("implement me")
3593+
// fetchFunc := func(ctx context.Context, id uuid.UUID) (database.NotificationsInbox, error) {
3594+
// return q.db.GetInboxNotificationByID(ctx, id)
3595+
// }
35953596

3596-
updateFunc:=func(ctx context.Context,arg database.SetInboxNotificationAsReadParams)error {
3597-
returnq.db.SetInboxNotificationAsRead(ctx,arg)
3598-
}
3597+
//updateFunc := func(ctx context.Context, arg database.SetInboxNotificationAsReadParams) error {
3598+
//return q.db.SetInboxNotificationAsRead(ctx, arg)
3599+
//}
35993600

3600-
returnupdate(q.log,q.auth,fetchFunc,updateFunc)(ctx,arg)
3601+
//return update(q.log, q.auth, fetchFunc, updateFunc)(ctx, arg)
36013602
}
36023603

36033604
func (q*querier)TryAcquireLock(ctx context.Context,idint64) (bool,error) {

‎coderd/database/dbmem/dbmem.go

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func New() database.Store {
6767
gitSSHKey:make([]database.GitSSHKey,0),
6868
notificationMessages:make([]database.NotificationMessage,0),
6969
notificationPreferences:make([]database.NotificationPreference,0),
70+
notificationsInbox:make([]database.NotificationsInbox,0),
7071
parameterSchemas:make([]database.ParameterSchema,0),
7172
provisionerDaemons:make([]database.ProvisionerDaemon,0),
7273
provisionerKeys:make([]database.ProvisionerKey,0),
@@ -206,6 +207,7 @@ type data struct {
206207
notificationMessages []database.NotificationMessage
207208
notificationPreferences []database.NotificationPreference
208209
notificationReportGeneratorLogs []database.NotificationReportGeneratorLog
210+
notificationsInbox []database.NotificationsInbox
209211
oauth2ProviderApps []database.OAuth2ProviderApp
210212
oauth2ProviderAppSecrets []database.OAuth2ProviderAppSecret
211213
oauth2ProviderAppCodes []database.OAuth2ProviderAppCode
@@ -2363,17 +2365,32 @@ func (q *FakeQuerier) FavoriteWorkspace(_ context.Context, arg uuid.UUID) error
23632365
returnnil
23642366
}
23652367

2366-
func (q*FakeQuerier)FetchInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
2367-
panic("not implemented")
2368+
func (q*FakeQuerier)FetchInboxNotificationsByUserID(_ context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
2369+
q.mutex.RLock()
2370+
deferq.mutex.RUnlock()
2371+
2372+
notifications:=make([]database.NotificationsInbox,0)
2373+
for_,notification:=rangeq.notificationsInbox {
2374+
ifnotification.UserID==userID {
2375+
notifications=append(notifications,notification)
2376+
}
2377+
}
2378+
2379+
returnnotifications,nil
23682380
}
23692381

2370-
func (q*FakeQuerier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
2371-
err:=validateDatabaseType(arg)
2372-
iferr!=nil {
2373-
returnnil,err
2382+
func (q*FakeQuerier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID(_ context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
2383+
q.mutex.RLock()
2384+
deferq.mutex.RUnlock()
2385+
2386+
notifications:=make([]database.NotificationsInbox,0)
2387+
for_,notification:=rangeq.notificationsInbox {
2388+
ifnotification.UserID==arg.UserID&&notification.TemplateID==arg.TemplateID&&notification.TargetID==arg.TargetID {
2389+
notifications=append(notifications,notification)
2390+
}
23742391
}
23752392

2376-
panic("not implemented")
2393+
returnnotifications,nil
23772394
}
23782395

23792396
func (q*FakeQuerier)FetchMemoryResourceMonitorsByAgentID(_ context.Context,agentID uuid.UUID) (database.WorkspaceAgentMemoryResourceMonitor,error) {
@@ -2418,17 +2435,32 @@ func (q *FakeQuerier) FetchNewMessageMetadata(_ context.Context, arg database.Fe
24182435
},nil
24192436
}
24202437

2421-
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
2422-
panic("not implemented")
2438+
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserID(_ context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
2439+
q.mutex.RLock()
2440+
deferq.mutex.RUnlock()
2441+
2442+
notifications:=make([]database.NotificationsInbox,0)
2443+
for_,notification:=rangeq.notificationsInbox {
2444+
ifnotification.UserID==userID&&!notification.ReadAt.Valid {
2445+
notifications=append(notifications,notification)
2446+
}
2447+
}
2448+
2449+
returnnotifications,nil
24232450
}
24242451

2425-
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
2426-
err:=validateDatabaseType(arg)
2427-
iferr!=nil {
2428-
returnnil,err
2452+
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID(_ context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
2453+
q.mutex.RLock()
2454+
deferq.mutex.RUnlock()
2455+
2456+
notifications:=make([]database.NotificationsInbox,0)
2457+
for_,notification:=rangeq.notificationsInbox {
2458+
ifnotification.UserID==arg.UserID&&notification.TemplateID==arg.TemplateID&&notification.TargetID==arg.TargetID&&!notification.ReadAt.Valid {
2459+
notifications=append(notifications,notification)
2460+
}
24292461
}
24302462

2431-
panic("not implemented")
2463+
returnnotifications,nil
24322464
}
24332465

24342466
func (q*FakeQuerier)FetchVolumesResourceMonitorsByAgentID(_ context.Context,agentID uuid.UUID) ([]database.WorkspaceAgentVolumeResourceMonitor,error) {
@@ -3358,8 +3390,17 @@ func (q *FakeQuerier) GetHungProvisionerJobs(_ context.Context, hungSince time.T
33583390
returnhungJobs,nil
33593391
}
33603392

3361-
func (q*FakeQuerier)GetInboxNotificationByID(ctx context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
3362-
panic("not implemented")
3393+
func (q*FakeQuerier)GetInboxNotificationByID(_ context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
3394+
q.mutex.RLock()
3395+
deferq.mutex.RUnlock()
3396+
3397+
for_,notification:=rangeq.notificationsInbox {
3398+
ifnotification.ID==id {
3399+
returnnotification,nil
3400+
}
3401+
}
3402+
3403+
return database.NotificationsInbox{},sql.ErrNoRows
33633404
}
33643405

33653406
func (q*FakeQuerier)GetJFrogXrayScanByWorkspaceAndAgentID(_ context.Context,arg database.GetJFrogXrayScanByWorkspaceAndAgentIDParams) (database.JfrogXrayScan,error) {
@@ -7989,13 +8030,28 @@ func (q *FakeQuerier) InsertGroupMember(_ context.Context, arg database.InsertGr
79898030
returnnil
79908031
}
79918032

7992-
func (q*FakeQuerier)InsertInboxNotification(ctx context.Context,arg database.InsertInboxNotificationParams) (database.NotificationsInbox,error) {
7993-
err:=validateDatabaseType(arg)
7994-
iferr!=nil {
8033+
func (q*FakeQuerier)InsertInboxNotification(_ context.Context,arg database.InsertInboxNotificationParams) (database.NotificationsInbox,error) {
8034+
iferr:=validateDatabaseType(arg);err!=nil {
79958035
return database.NotificationsInbox{},err
79968036
}
79978037

7998-
panic("not implemented")
8038+
q.mutex.Lock()
8039+
deferq.mutex.Unlock()
8040+
8041+
notification:= database.NotificationsInbox{
8042+
ID:arg.ID,
8043+
UserID:arg.UserID,
8044+
TemplateID:arg.TemplateID,
8045+
TargetID:arg.TargetID,
8046+
Title:arg.Title,
8047+
Content:arg.Content,
8048+
Icon:arg.Icon,
8049+
Actions:arg.Actions,
8050+
CreatedAt:time.Now(),
8051+
}
8052+
8053+
q.notificationsInbox=append(q.notificationsInbox,notification)
8054+
returnnotification,nil
79998055
}
80008056

80018057
func (q*FakeQuerier)InsertLicense(
@@ -9482,13 +9538,22 @@ func (q *FakeQuerier) RevokeDBCryptKey(_ context.Context, activeKeyDigest string
94829538
returnsql.ErrNoRows
94839539
}
94849540

9485-
func (q*FakeQuerier)SetInboxNotificationAsRead(ctx context.Context,arg database.SetInboxNotificationAsReadParams)error {
9541+
func (q*FakeQuerier)SetInboxNotificationAsRead(_ context.Context,arg database.SetInboxNotificationAsReadParams)error {
94869542
err:=validateDatabaseType(arg)
94879543
iferr!=nil {
94889544
returnerr
94899545
}
94909546

9491-
panic("not implemented")
9547+
q.mutex.Lock()
9548+
deferq.mutex.Unlock()
9549+
9550+
fori:=rangeq.notificationsInbox {
9551+
ifq.notificationsInbox[i].ID==arg.ID {
9552+
q.notificationsInbox[i].ReadAt=arg.ReadAt
9553+
}
9554+
}
9555+
9556+
returnnil
94929557
}
94939558

94949559
func (*FakeQuerier)TryAcquireLock(_ context.Context,_int64) (bool,error) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp