@meith/db 0.17.0 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meith/db",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,35 +22,35 @@
22
22
  "dependencies": {
23
23
  "drizzle-orm": "^0.45.2",
24
24
  "postgres": "^3.4.7",
25
- "@meith/accounts": "0.17.0",
26
- "@meith/admin": "0.17.0",
27
- "@meith/antispam": "0.17.0",
28
- "@meith/attachments": "0.17.0",
29
- "@meith/api": "0.17.0",
30
- "@meith/authorization": "0.17.0",
31
- "@meith/avatars": "0.17.0",
32
- "@meith/events": "0.17.0",
33
- "@meith/drafts": "0.17.0",
34
- "@meith/forums": "0.17.0",
35
- "@meith/core": "0.17.0",
36
- "@meith/groups": "0.17.0",
37
- "@meith/i18n": "0.17.0",
38
- "@meith/marketplace": "0.17.0",
39
- "@meith/moderation": "0.17.0",
40
- "@meith/markdown": "0.17.0",
41
- "@meith/plugin-kit": "0.17.0",
42
- "@meith/notifications": "0.17.0",
43
- "@meith/polls": "0.17.0",
44
- "@meith/profile-fields": "0.17.0",
45
- "@meith/relations": "0.17.0",
46
- "@meith/reputation": "0.17.0",
47
- "@meith/search": "0.17.0",
48
- "@meith/signatures": "0.17.0",
49
- "@meith/settings": "0.17.0",
50
- "@meith/messages": "0.17.0",
51
- "@meith/tasks": "0.17.0",
52
- "@meith/threads": "0.17.0",
53
- "@meith/subscriptions": "0.17.0"
25
+ "@meith/accounts": "0.17.2",
26
+ "@meith/antispam": "0.17.2",
27
+ "@meith/admin": "0.17.2",
28
+ "@meith/authorization": "0.17.2",
29
+ "@meith/attachments": "0.17.2",
30
+ "@meith/api": "0.17.2",
31
+ "@meith/avatars": "0.17.2",
32
+ "@meith/core": "0.17.2",
33
+ "@meith/drafts": "0.17.2",
34
+ "@meith/events": "0.17.2",
35
+ "@meith/forums": "0.17.2",
36
+ "@meith/i18n": "0.17.2",
37
+ "@meith/groups": "0.17.2",
38
+ "@meith/marketplace": "0.17.2",
39
+ "@meith/messages": "0.17.2",
40
+ "@meith/markdown": "0.17.2",
41
+ "@meith/moderation": "0.17.2",
42
+ "@meith/notifications": "0.17.2",
43
+ "@meith/plugin-kit": "0.17.2",
44
+ "@meith/polls": "0.17.2",
45
+ "@meith/relations": "0.17.2",
46
+ "@meith/profile-fields": "0.17.2",
47
+ "@meith/reputation": "0.17.2",
48
+ "@meith/search": "0.17.2",
49
+ "@meith/subscriptions": "0.17.2",
50
+ "@meith/settings": "0.17.2",
51
+ "@meith/tasks": "0.17.2",
52
+ "@meith/threads": "0.17.2",
53
+ "@meith/signatures": "0.17.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "drizzle-kit": "^0.31.6",
@@ -82,30 +82,23 @@ export class PostgresMarketplaceCacheRepository implements MarketplaceCacheRepos
82
82
  `)
83
83
  }
84
84
 
85
- async hasNotified(key: string, version: string): Promise<boolean> {
85
+ async claimNotified(key: string, version: string): Promise<boolean> {
86
+ const marker = `${key}@${version}`
86
87
  const rows = resultRows(
87
88
  await this.db.execute(sql`
88
- select 1
89
- from marketplace_catalog
90
- where id = 1
91
- and notified_updates @> ${JSON.stringify([`${key}@${version}`])}::jsonb
89
+ insert into marketplace_catalog (id, notified_updates, updated_at)
90
+ values (1, ${JSON.stringify([marker])}::jsonb, now())
91
+ on conflict (id) do update
92
+ set notified_updates = (
93
+ select jsonb_agg(distinct value)
94
+ from jsonb_array_elements(marketplace_catalog.notified_updates || excluded.notified_updates)
95
+ ),
96
+ updated_at = now()
97
+ where not (marketplace_catalog.notified_updates @> excluded.notified_updates)
98
+ returning 1
92
99
  `),
93
100
  ) as unknown[]
94
101
 
95
102
  return rows.length > 0
96
103
  }
97
-
98
- async markNotified(key: string, version: string): Promise<void> {
99
- const marker = `${key}@${version}`
100
- await this.db.execute(sql`
101
- insert into marketplace_catalog (id, notified_updates, updated_at)
102
- values (1, ${JSON.stringify([marker])}::jsonb, now())
103
- on conflict (id) do update
104
- set notified_updates = (
105
- select jsonb_agg(distinct value)
106
- from jsonb_array_elements(marketplace_catalog.notified_updates || excluded.notified_updates)
107
- ),
108
- updated_at = now()
109
- `)
110
- }
111
104
  }