@steedos/service-fields-indexs 2.3.6 → 2.3.7

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.
@@ -2,7 +2,7 @@
2
2
  * @Author: baozhoutao@hotoa.com
3
3
  * @Date: 2022-02-28 09:25:03
4
4
  * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2023-01-10 11:59:22
5
+ * @LastEditTime: 2022-11-30 14:15:57
6
6
  * @Description:
7
7
  */
8
8
  if (Meteor.isServer) {
@@ -16,7 +16,7 @@ if (Meteor.isServer) {
16
16
  background: true
17
17
  });
18
18
  } catch (error) {
19
-
19
+
20
20
  }
21
21
  try {
22
22
  db.instances._ensureIndex({
@@ -25,7 +25,7 @@ if (Meteor.isServer) {
25
25
  background: true
26
26
  });
27
27
  } catch (error) {
28
-
28
+
29
29
  }
30
30
  try {
31
31
  db.instances._ensureIndex({
@@ -34,7 +34,7 @@ if (Meteor.isServer) {
34
34
  background: true
35
35
  });
36
36
  } catch (error) {
37
-
37
+
38
38
  }
39
39
  try {
40
40
  db.instances._ensureIndex({
@@ -43,7 +43,7 @@ if (Meteor.isServer) {
43
43
  background: true
44
44
  });
45
45
  } catch (error) {
46
-
46
+
47
47
  }
48
48
  db.instances._ensureIndex({
49
49
  "space": 1,
@@ -225,7 +225,7 @@ if (Meteor.isServer) {
225
225
  background: true
226
226
  });
227
227
  } catch (error) {
228
-
228
+
229
229
  }
230
230
  db.instances._ensureIndex({
231
231
  "record_ids.o": 1,
@@ -238,57 +238,4 @@ if (Meteor.isServer) {
238
238
  }, {
239
239
  background: true
240
240
  });
241
-
242
- // 监控箱-管理员
243
- try {
244
- db.instances._ensureIndex({
245
- space: 1,
246
- state: 1,
247
- submit_date: -1,
248
- }, { background: true, name: 'monitor_admin' });
249
- } catch (error) {
250
-
251
- }
252
-
253
- // 监控箱-用户
254
- try {
255
- db.instances._ensureIndex({
256
- flow: 1,
257
- }, { background: true });
258
- } catch (error) {
259
-
260
- }
261
-
262
- // 草稿箱
263
- try {
264
- db.instances._ensureIndex({
265
- space: 1,
266
- submitter: 1,
267
- state: 1,
268
- modified: -1,
269
- }, { background: true, name: 'draft' });
270
- } catch (error) {
271
-
272
- }
273
-
274
- // 进行中
275
- try {
276
- db.instances._ensureIndex({
277
- space: 1,
278
- state: 1,
279
- modified: -1,
280
- }, { background: true, name: 'pending' });
281
- } catch (error) {
282
-
283
- }
284
- try {
285
- db.instances._ensureIndex({
286
- space: 1,
287
- state: 1,
288
- applicant: 1,
289
- modified: -1,
290
- }, { background: true, name: 'pending_applicant' });
291
- } catch (error) {
292
-
293
- }
294
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-fields-indexs",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -10,5 +10,5 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "gitHead": "3ef6bf3744c616d6a961b3264e5f204b9697ef6a"
13
+ "gitHead": "e81279db5d8aab35332334cf3eeecf5fd8ead99f"
14
14
  }
@@ -35,9 +35,9 @@ module.exports = {
35
35
  async handler(ctx) {
36
36
  this.logger.debug(`refreshIndexes start`);
37
37
  const objects = await ctx.call(`objects.getAll`, {});
38
- for await (const object of objects) {
38
+ for await(const object of objects) {
39
39
  const objectAPIName = object.metadata.name;
40
- if (objectAPIName && !objectAPIName.startsWith('__')) {
40
+ if(objectAPIName && !objectAPIName.startsWith('__')){
41
41
  await objectql.getObject(objectAPIName).refreshIndexes()
42
42
  }
43
43
  }
@@ -59,18 +59,6 @@ module.exports = {
59
59
  console.error(`refresh indexe error: ${matchedPath}`, error);
60
60
  }
61
61
  });
62
-
63
- const indexFilePatten = [
64
- path.join(__dirname, 'collection-indexes', "*.index.js")
65
- ];
66
- const matchedIndexPaths = metaDataCore.syncMatchFiles(indexFilePatten);
67
- _.each(matchedIndexPaths, (matchedPath) => {
68
- try {
69
- require(matchedPath).run();
70
- } catch (error) {
71
- console.error(`refresh indexe error: ${matchedPath}`, error);
72
- }
73
- });
74
62
  this.logger.debug(`refreshIndexes end`);
75
63
  return 'success'
76
64
  }
@@ -106,11 +94,11 @@ module.exports = {
106
94
  let indexScheduleCron = "0 0 * * * *"; // 默认每小时执行一次
107
95
  const steedosConfig = objectql.getSteedosConfig() || {};
108
96
  const cron = steedosConfig.cron;
109
- if (cron && cron.build_index) {
97
+ if(cron && cron.build_index){
110
98
  indexScheduleCron = cron.build_index;
111
99
  }
112
100
  if (indexScheduleCron) {
113
- this.job = schedule.scheduleJob(indexScheduleCron, () => {
101
+ this.job = schedule.scheduleJob(indexScheduleCron, ()=>{
114
102
  this.broker.call(`${serviceName}.refreshIndexes`)
115
103
  });
116
104
  }
@@ -123,7 +111,7 @@ module.exports = {
123
111
  * Service stopped lifecycle event handler
124
112
  */
125
113
  async stopped() {
126
- if (this.job && this.job.cancel) {
114
+ if(this.job && this.job.cancel){
127
115
  this.job.cancel()
128
116
  }
129
117
  }
@@ -1,22 +0,0 @@
1
- /*
2
- * @Author: sunhaolin@hotoa.com
3
- * @Date: 2023-01-10 11:35:36
4
- * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2023-01-10 13:45:33
6
- * @Description:
7
- */
8
- const objectql = require('@steedos/objectql')
9
-
10
- async function getCollection(collectionName) {
11
- try {
12
- const adapter = objectql.getObject(collectionName).datasource.adapter
13
- await adapter.connect()
14
- return adapter.collection(collectionName);
15
- } catch (error) {
16
- return null
17
- }
18
- }
19
-
20
- module.exports = {
21
- getCollection
22
- }
@@ -1,52 +0,0 @@
1
- /*
2
- * @Author: sunhaolin@hotoa.com
3
- * @Date: 2023-01-10 11:28:54
4
- * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2023-01-10 14:33:11
6
- * @Description:
7
- */
8
- const db = require('./default_db')
9
-
10
-
11
- async function run() {
12
- const collection = await db.getCollection('instance_tasks')
13
-
14
- // 待审核箱
15
- try {
16
- const indexName = 'inbox'
17
- const indexExists = await collection.indexExists(indexName)
18
- if (!indexExists) {
19
- await collection.createIndex({
20
- space: 1,
21
- handler: 1,
22
- is_finished: 1,
23
- instance_state: 1,
24
- distribute_from_instance: 1,
25
- forward_from_instance: 1,
26
- is_hidden: 1,
27
- start_date: -1
28
- }, { background: true, name: indexName })
29
- }
30
- } catch (error) {
31
- console.error(error)
32
- }
33
- // 已审核箱
34
- try {
35
- const indexName = 'outbox'
36
- const indexExists = await collection.indexExists(indexName)
37
- if (!indexExists) {
38
- await collection.createIndex({
39
- space: 1,
40
- handler: 1,
41
- is_finished: 1,
42
- finish_date: -1,
43
- }, { background: true, name: indexName })
44
- }
45
- } catch (error) {
46
- console.error(error)
47
- }
48
- }
49
-
50
- module.exports = {
51
- run
52
- }