Skip to content

Commit 90c7b64

Browse files
committed
work on db queries
1 parent dedc32f commit 90c7b64

File tree

12 files changed

+530
-0
lines changed

12 files changed

+530
-0
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,14 @@ func (q *querier) FavoriteWorkspace(ctx context.Context, id uuid.UUID) error {
14171417
return update(q.log, q.auth, fetch, q.db.FavoriteWorkspace)(ctx, id)
14181418
}
14191419

1420+
func (q *querier) FetchInboxNotificationsByUserID(ctx context.Context, userID uuid.UUID) ([]database.NotificationsInbox, error) {
1421+
panic("not implemented")
1422+
}
1423+
1424+
func (q *querier) FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context, arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox, error) {
1425+
panic("not implemented")
1426+
}
1427+
14201428
func (q *querier) FetchMemoryResourceMonitorsByAgentID(ctx context.Context, agentID uuid.UUID) (database.WorkspaceAgentMemoryResourceMonitor, error) {
14211429
workspace, err := q.db.GetWorkspaceByAgentID(ctx, agentID)
14221430
if err != nil {
@@ -1438,6 +1446,14 @@ func (q *querier) FetchNewMessageMetadata(ctx context.Context, arg database.Fetc
14381446
return q.db.FetchNewMessageMetadata(ctx, arg)
14391447
}
14401448

1449+
func (q *querier) FetchUnreadInboxNotificationsByUserID(ctx context.Context, userID uuid.UUID) ([]database.NotificationsInbox, error) {
1450+
panic("not implemented")
1451+
}
1452+
1453+
func (q *querier) FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context, arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox, error) {
1454+
panic("not implemented")
1455+
}
1456+
14411457
func (q *querier) FetchVolumesResourceMonitorsByAgentID(ctx context.Context, agentID uuid.UUID) ([]database.WorkspaceAgentVolumeResourceMonitor, error) {
14421458
workspace, err := q.db.GetWorkspaceByAgentID(ctx, agentID)
14431459
if err != nil {
@@ -3077,6 +3093,10 @@ func (q *querier) InsertGroupMember(ctx context.Context, arg database.InsertGrou
30773093
return update(q.log, q.auth, fetch, q.db.InsertGroupMember)(ctx, arg)
30783094
}
30793095

3096+
func (q *querier) InsertInboxNotification(ctx context.Context, arg database.InsertInboxNotificationParams) (database.NotificationsInbox, error) {
3097+
panic("not implemented")
3098+
}
3099+
30803100
func (q *querier) InsertLicense(ctx context.Context, arg database.InsertLicenseParams) (database.License, error) {
30813101
if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceLicense); err != nil {
30823102
return database.License{}, err
@@ -3564,6 +3584,10 @@ func (q *querier) RevokeDBCryptKey(ctx context.Context, activeKeyDigest string)
35643584
return q.db.RevokeDBCryptKey(ctx, activeKeyDigest)
35653585
}
35663586

3587+
func (q *querier) SetInboxNotificationAsRead(ctx context.Context, arg database.SetInboxNotificationAsReadParams) error {
3588+
panic("not implemented")
3589+
}
3590+
35673591
func (q *querier) TryAcquireLock(ctx context.Context, id int64) (bool, error) {
35683592
return q.db.TryAcquireLock(ctx, id)
35693593
}

coderd/database/dbmem/dbmem.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,6 +2363,19 @@ func (q *FakeQuerier) FavoriteWorkspace(_ context.Context, arg uuid.UUID) error
23632363
return nil
23642364
}
23652365

2366+
func (q *FakeQuerier) FetchInboxNotificationsByUserID(ctx context.Context, userID uuid.UUID) ([]database.NotificationsInbox, error) {
2367+
panic("not implemented")
2368+
}
2369+
2370+
func (q *FakeQuerier) FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context, arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox, error) {
2371+
err := validateDatabaseType(arg)
2372+
if err != nil {
2373+
return nil, err
2374+
}
2375+
2376+
panic("not implemented")
2377+
}
2378+
23662379
func (q *FakeQuerier) FetchMemoryResourceMonitorsByAgentID(_ context.Context, agentID uuid.UUID) (database.WorkspaceAgentMemoryResourceMonitor, error) {
23672380
for _, monitor := range q.workspaceAgentMemoryResourceMonitors {
23682381
if monitor.AgentID == agentID {
@@ -2405,6 +2418,19 @@ func (q *FakeQuerier) FetchNewMessageMetadata(_ context.Context, arg database.Fe
24052418
}, nil
24062419
}
24072420

2421+
func (q *FakeQuerier) FetchUnreadInboxNotificationsByUserID(ctx context.Context, userID uuid.UUID) ([]database.NotificationsInbox, error) {
2422+
panic("not implemented")
2423+
}
2424+
2425+
func (q *FakeQuerier) FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID(ctx context.Context, arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams) ([]database.NotificationsInbox, error) {
2426+
err := validateDatabaseType(arg)
2427+
if err != nil {
2428+
return nil, err
2429+
}
2430+
2431+
panic("not implemented")
2432+
}
2433+
24082434
func (q *FakeQuerier) FetchVolumesResourceMonitorsByAgentID(_ context.Context, agentID uuid.UUID) ([]database.WorkspaceAgentVolumeResourceMonitor, error) {
24092435
monitors := []database.WorkspaceAgentVolumeResourceMonitor{}
24102436

@@ -7959,6 +7985,15 @@ func (q *FakeQuerier) InsertGroupMember(_ context.Context, arg database.InsertGr
79597985
return nil
79607986
}
79617987

7988+
func (q *FakeQuerier) InsertInboxNotification(ctx context.Context, arg database.InsertInboxNotificationParams) (database.NotificationsInbox, error) {
7989+
err := validateDatabaseType(arg)
7990+
if err != nil {
7991+
return database.NotificationsInbox{}, err
7992+
}
7993+
7994+
panic("not implemented")
7995+
}
7996+
79627997
func (q *FakeQuerier) InsertLicense(
79637998
_ context.Context, arg database.InsertLicenseParams,
79647999
) (database.License, error) {
@@ -9443,6 +9478,15 @@ func (q *FakeQuerier) RevokeDBCryptKey(_ context.Context, activeKeyDigest string
94439478
return sql.ErrNoRows
94449479
}
94459480

9481+
func (q *FakeQuerier) SetInboxNotificationAsRead(ctx context.Context, arg database.SetInboxNotificationAsReadParams) error {
9482+
err := validateDatabaseType(arg)
9483+
if err != nil {
9484+
return err
9485+
}
9486+
9487+
panic("not implemented")
9488+
}
9489+
94469490
func (*FakeQuerier) TryAcquireLock(_ context.Context, _ int64) (bool, error) {
94479491
return false, xerrors.New("TryAcquireLock must only be called within a transaction")
94489492
}

coderd/database/dbmetrics/querymetrics.go

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbmock/dbmock.go

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dump.sql

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE IF EXISTS notifications_inbox;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CREATE TABLE notifications_inbox (
2+
id UUID PRIMARY KEY,
3+
user_id UUID NOT NULL,
4+
template_id UUID NOT NULL,
5+
target_id UUID,
6+
title TEXT NOT NULL,
7+
content TEXT NOT NULL,
8+
icon TEXT NOT NULL,
9+
actions JSONB NOT NULL,
10+
read_at TIMESTAMP WITH TIME ZONE,
11+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
12+
);
13+
14+
CREATE INDEX idx_notifications_inbox_user_id_read_at ON notifications_inbox(user_id, read_at);
15+
CREATE INDEX idx_notifications_inbox_user_id_template_id_target_id ON notifications_inbox(user_id, template_id, target_id);

coderd/database/models.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)