@social-mail/social-mail-web-server 1.4.891 → 1.4.892

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": "@social-mail/social-mail-web-server",
3
- "version": "1.4.891",
3
+ "version": "1.4.892",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@aws-sdk/client-s3": "^3.609.0",
23
23
  "@azure/storage-blob": "^12.23.0",
24
- "@entity-access/entity-access": "^1.0.349",
24
+ "@entity-access/entity-access": "^1.0.350",
25
25
  "@entity-access/server-pages": "^1.1.222",
26
26
  "@otplib/preset-v11": "^12.0.1",
27
27
  "@social-mail/noto-emoji-svg": "^2.0.42",
@@ -11,28 +11,39 @@ export default class StoreTagCountService {
11
11
 
12
12
  async updateCounts(entity: StoreItem, diff: number) {
13
13
  const { db } = this;
14
- const { storeItemID } = entity;
15
- const updated = await db.storeTags.where(entity, (p) => (x) => x.storeID === p.storeID)
16
- .where(entity, (p) => (x) => x.tag.storeItemTags.some((sit) => sit.storeItemID === p.storeItemID))
17
- .update({ diff, storeItemID }, (p) => (x) => ({
18
- count: x.count + Sql.cast.asInteger(p.diff) * Sql.coll.sum(x.store.storeItems
19
- .filter((si) => si.storeItemID === p.storeItemID)
20
- .map((si) => Sql.coll.sum(si.storeItemTags
21
- .filter((t) => t.tagID === x.tagID)
22
- .map((t) => 1))))
23
- }));
24
- if (!updated) {
25
- // insert...
26
- await db.storeItemTags.where(entity, (p) => (x) => x.storeItemID === p.storeItemID)
27
- .select({ diff }, (p) => (x) => ({
28
- storeID: x.storeItem.storeID,
29
- tagID: x.tagID,
30
- count: Sql.cast.asInteger(p.diff) * Sql.coll.sum(x.tag.storeItemTags
31
- .filter((sit) => sit.storeItem.storeID === x.storeItem.storeID)
32
- .map((sit) => 1))
33
- }))
34
- .insertInTo(db.storeTags);
14
+ const { storeItemID, storeID } = entity;
15
+
16
+ const items = await db.storeItemTags.where(entity, (p) => (x) => x.storeItemID === p.storeItemID)
17
+ .toArray();
18
+
19
+ for (const { tagID } of items) {
20
+ const ti = { tagID , storeID };
21
+ const count = diff * (await db.storeItemTags.where(ti, (p) => (x) => x.tagID === p.tagID && x.storeItem.storeID === p.storeID)
22
+ .count());
23
+ await db.storeTags.statements.upsert({ tagID, storeID, count}, void 0, { tagID, storeID });
35
24
  }
25
+
26
+ // const updated = await db.storeTags.where(entity, (p) => (x) => x.storeID === p.storeID)
27
+ // .where(entity, (p) => (x) => x.tag.storeItemTags.some((sit) => sit.storeItemID === p.storeItemID))
28
+ // .update({ diff, storeItemID }, (p) => (x) => ({
29
+ // count: x.count + Sql.cast.asInteger(p.diff) * Sql.coll.sum(x.store.storeItems
30
+ // .filter((si) => si.storeItemID === p.storeItemID)
31
+ // .map((si) => Sql.coll.sum(si.storeItemTags
32
+ // .filter((t) => t.tagID === x.tagID)
33
+ // .map((t) => 1))))
34
+ // }));
35
+ // if (!updated) {
36
+ // // insert...
37
+ // await db.storeItemTags.where(entity, (p) => (x) => x.storeItemID === p.storeItemID)
38
+ // .select({ diff }, (p) => (x) => ({
39
+ // storeID: x.storeItem.storeID,
40
+ // tagID: x.tagID,
41
+ // count: Sql.cast.asInteger(p.diff) * Sql.coll.sum(x.tag.storeItemTags
42
+ // .filter((sit) => sit.storeItem.storeID === x.storeItem.storeID)
43
+ // .map((sit) => 1))
44
+ // }))
45
+ // .insertInTo(db.storeTags);
46
+ // }
36
47
  }
37
48
 
38
49
  }