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

Commitfddf156

Browse files
committed
change queries to match targets
1 parenta7a88e0 commitfddf156

File tree

10 files changed

+123
-100
lines changed

10 files changed

+123
-100
lines changed

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,8 +1421,8 @@ func (q *querier) FetchInboxNotificationsByUserID(ctx context.Context, userID uu
14211421
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserID)(ctx,userID)
14221422
}
14231423

1424-
func (q*querier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
1425-
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID)(ctx,arg)
1424+
func (q*querier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargets(ctx context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
1425+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserIDAndTemplateIDAndTargets)(ctx,arg)
14261426
}
14271427

14281428
func (q*querier)FetchMemoryResourceMonitorsByAgentID(ctx context.Context,agentID uuid.UUID) (database.WorkspaceAgentMemoryResourceMonitor,error) {
@@ -1450,8 +1450,8 @@ func (q *querier) FetchUnreadInboxNotificationsByUserID(ctx context.Context, use
14501450
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserID)(ctx,userID)
14511451
}
14521452

1453-
func (q*querier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
1454-
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID)(ctx,arg)
1453+
func (q*querier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargets(ctx context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
1454+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargets)(ctx,arg)
14551455
}
14561456

14571457
func (q*querier)FetchVolumesResourceMonitorsByAgentID(ctx context.Context,agentID uuid.UUID) ([]database.WorkspaceAgentVolumeResourceMonitor,error) {
@@ -3588,17 +3588,12 @@ func (q *querier) RevokeDBCryptKey(ctx context.Context, activeKeyDigest string)
35883588
returnq.db.RevokeDBCryptKey(ctx,activeKeyDigest)
35893589
}
35903590

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-
// }
3596-
3597-
// updateFunc := func(ctx context.Context, arg database.SetInboxNotificationAsReadParams) error {
3598-
// return q.db.SetInboxNotificationAsRead(ctx, arg)
3599-
// }
3591+
func (q*querier)SetInboxNotificationAsRead(ctx context.Context,args database.SetInboxNotificationAsReadParams)error {
3592+
fetchFunc:=func(ctx context.Context,args database.SetInboxNotificationAsReadParams) (database.NotificationsInbox,error) {
3593+
returnq.db.GetInboxNotificationByID(ctx,args.ID)
3594+
}
36003595

3601-
//return update(q.log, q.auth, fetchFunc,updateFunc)(ctx,arg)
3596+
returnupdate(q.log,q.auth,fetchFunc,q.db.SetInboxNotificationAsRead)(ctx,args)
36023597
}
36033598

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

‎coderd/database/dbmem/dbmem.go

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,14 +2379,28 @@ func (q *FakeQuerier) FetchInboxNotificationsByUserID(_ context.Context, userID
23792379
returnnotifications,nil
23802380
}
23812381

2382-
func (q*FakeQuerier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID(_ context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
2382+
func (q*FakeQuerier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargets(_ context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
23832383
q.mutex.RLock()
23842384
deferq.mutex.RUnlock()
23852385

23862386
notifications:=make([]database.NotificationsInbox,0)
23872387
for_,notification:=rangeq.notificationsInbox {
2388-
ifnotification.UserID==arg.UserID&&notification.TemplateID==arg.TemplateID&&notification.TargetID==arg.TargetID {
2389-
notifications=append(notifications,notification)
2388+
ifnotification.UserID==arg.UserID&&notification.TemplateID==arg.TemplateID {
2389+
for_,target:=rangearg.Targets {
2390+
isFound:=false
2391+
for_,insertedTarget:=rangenotification.Targets {
2392+
ifinsertedTarget==target {
2393+
isFound=true
2394+
break
2395+
}
2396+
}
2397+
2398+
if!isFound {
2399+
continue
2400+
}
2401+
2402+
notifications=append(notifications,notification)
2403+
}
23902404
}
23912405
}
23922406

@@ -2449,14 +2463,28 @@ func (q *FakeQuerier) FetchUnreadInboxNotificationsByUserID(_ context.Context, u
24492463
returnnotifications,nil
24502464
}
24512465

2452-
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID(_ context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox,error) {
2466+
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargets(_ context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
24532467
q.mutex.RLock()
24542468
deferq.mutex.RUnlock()
24552469

24562470
notifications:=make([]database.NotificationsInbox,0)
24572471
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)
2472+
ifnotification.UserID==arg.UserID&&notification.TemplateID==arg.TemplateID&&!notification.ReadAt.Valid {
2473+
for_,target:=rangearg.Targets {
2474+
isFound:=false
2475+
for_,insertedTarget:=rangenotification.Targets {
2476+
ifinsertedTarget==target {
2477+
isFound=true
2478+
break
2479+
}
2480+
}
2481+
2482+
if!isFound {
2483+
continue
2484+
}
2485+
2486+
notifications=append(notifications,notification)
2487+
}
24602488
}
24612489
}
24622490

@@ -8042,7 +8070,7 @@ func (q *FakeQuerier) InsertInboxNotification(_ context.Context, arg database.In
80428070
ID:arg.ID,
80438071
UserID:arg.UserID,
80448072
TemplateID:arg.TemplateID,
8045-
TargetID:arg.TargetID,
8073+
Targets:arg.Targets,
80468074
Title:arg.Title,
80478075
Content:arg.Content,
80488076
Icon:arg.Icon,

‎coderd/database/dbmetrics/querymetrics.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbmock/dbmock.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dump.sql

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/migrations/000295_notifications_inbox.up.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CREATE TABLE notifications_inbox (
22
id UUIDPRIMARY KEY,
33
user_id UUIDNOT NULL,
44
template_id UUIDNOT NULL,
5-
target_id UUID,
5+
targets UUID[],
66
titleTEXTNOT NULL,
77
contentTEXTNOT NULL,
88
iconTEXTNOT NULL,
@@ -12,4 +12,4 @@ CREATE TABLE notifications_inbox (
1212
);
1313

1414
CREATEINDEXidx_notifications_inbox_user_id_read_atON notifications_inbox(user_id, read_at);
15-
CREATEINDEXidx_notifications_inbox_user_id_template_id_target_idON notifications_inbox(user_id, template_id,target_id);
15+
CREATEINDEXidx_notifications_inbox_user_id_template_id_targetsON notifications_inbox(user_id, template_id,targets);

‎coderd/database/models.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/querier.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp