@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 +30 -30
- package/src/marketplace-repo.ts +12 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meith/db",
|
|
3
|
-
"version": "0.17.
|
|
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.
|
|
26
|
-
"@meith/
|
|
27
|
-
"@meith/
|
|
28
|
-
"@meith/
|
|
29
|
-
"@meith/
|
|
30
|
-
"@meith/
|
|
31
|
-
"@meith/avatars": "0.17.
|
|
32
|
-
"@meith/
|
|
33
|
-
"@meith/drafts": "0.17.
|
|
34
|
-
"@meith/
|
|
35
|
-
"@meith/
|
|
36
|
-
"@meith/
|
|
37
|
-
"@meith/
|
|
38
|
-
"@meith/marketplace": "0.17.
|
|
39
|
-
"@meith/
|
|
40
|
-
"@meith/markdown": "0.17.
|
|
41
|
-
"@meith/
|
|
42
|
-
"@meith/notifications": "0.17.
|
|
43
|
-
"@meith/
|
|
44
|
-
"@meith/
|
|
45
|
-
"@meith/relations": "0.17.
|
|
46
|
-
"@meith/
|
|
47
|
-
"@meith/
|
|
48
|
-
"@meith/
|
|
49
|
-
"@meith/
|
|
50
|
-
"@meith/
|
|
51
|
-
"@meith/tasks": "0.17.
|
|
52
|
-
"@meith/threads": "0.17.
|
|
53
|
-
"@meith/
|
|
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",
|
package/src/marketplace-repo.ts
CHANGED
|
@@ -82,30 +82,23 @@ export class PostgresMarketplaceCacheRepository implements MarketplaceCacheRepos
|
|
|
82
82
|
`)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
async
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
}
|