@social-mail/social-mail-web-server 1.8.21 → 1.8.22

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.8.21",
3
+ "version": "1.8.22",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,11 +23,18 @@ export default class IndexAppFilesWorkflow extends Workflow {
23
23
  }
24
24
 
25
25
  async run() {
26
- await this.index();
26
+ let start = -1;
27
+ for(;;) {
28
+ start = await this.index(start);
29
+ if (!BigInt(start)) {
30
+ break;
31
+ }
32
+ }
27
33
  }
28
34
 
29
35
  @UniqueActivity
30
36
  async index(
37
+ start,
31
38
  @Inject db?: SocialMailContext,
32
39
  @Inject tempFileService?: TempFileService
33
40
  ) {
@@ -35,16 +42,33 @@ export default class IndexAppFilesWorkflow extends Workflow {
35
42
  db.verifyFilters = false;
36
43
  db.raiseEvents = false;
37
44
 
38
- const files = await db.appFiles
39
- .where(void 0, (p) => (x) => x.fileContentID !== null && x.fileContent.textDocumentID === null)
45
+ let q = db.appFiles
46
+ .where(void 0, (p) => (x) => x.fileContentID !== null && x.fileContent.textDocumentID === null);
47
+
48
+ if (BigInt(start) > 0) {
49
+ q = q.where({ start }, (p) => (x) => x.appFileID < p.start);
50
+ }
51
+
52
+ const files = await q
40
53
  .orderByDescending(void 0, (p) => (x) => x.appFileID)
41
54
  .limit(100)
42
55
  .include((x) => x.fileContent)
43
56
  .toArray();
44
57
 
58
+ if (!files.length) {
59
+ return 0;
60
+ }
61
+
45
62
  for (const iterator of files) {
46
- await this.saveTextContent(iterator, tempFileService, db);
63
+ start = iterator.appFileID;
64
+ try {
65
+ await this.saveTextContent(iterator, tempFileService, db);
66
+ } catch (error) {
67
+ console.error(error);
68
+ }
47
69
  }
70
+
71
+ return start;
48
72
  }
49
73
 
50
74
  private async extractText(file: LocalFile, tempFileService: TempFileService, db: SocialMailContext) {