tabletcommand-incident 0.6.8 → 0.6.10

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/src/test/mock.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash";
2
- import { Collection } from "mongodb";
3
2
  import {
4
3
  BackendModels,
5
4
  CADIncident,
@@ -411,6 +410,57 @@ export default function({
411
410
  "ClosedDateTime": "2022-10-26T17:19:49-04:00",
412
411
  }
413
412
  },
413
+ {
414
+ departmentId,
415
+ "incidentNumber": "DEMO-RTS-0003",
416
+ "createdAt": new Date("2022-10-26T22:03:10.101+0000"),
417
+ "payload": {
418
+ "AgencyID": "Demo RTS AgencyId",
419
+ "IncidentNumber": "DEMO-RTS-0003",
420
+ "AgencyIncidentCallTypeDescription": "Test Description 3",
421
+ "EntryDateTime": "2022-10-26T17:09:49-04:00",
422
+ "Longitude": "-115.355705",
423
+ "Latitude": "37.959790",
424
+ "ClosedDateTime": "",
425
+ "LocationComment": "100 Bono Dr",
426
+ }
427
+ },
428
+ {
429
+ departmentId,
430
+ "incidentNumber": "DEMO-RTS-0003",
431
+ "createdAt": new Date("2022-10-26T22:03:10.201+0000"),
432
+ "payload": {
433
+ "AgencyID": "Demo RTS AgencyId",
434
+ "IncidentNumber": "DEMO-RTS-0003",
435
+ "EntryDateTime": "2022-10-26T17:09:49-04:00",
436
+ "ClosedDateTime": "",
437
+ "CommonPlaceName": "East Housing",
438
+ }
439
+ },
440
+ {
441
+ departmentId,
442
+ "incidentNumber": "DEMO-RTS-0003",
443
+ "createdAt": new Date("2022-10-26T22:03:10.301+0000"),
444
+ "payload": {
445
+ "AgencyID": "Demo RTS AgencyId",
446
+ "IncidentNumber": "DEMO-RTS-0003",
447
+ "EntryDateTime": "2022-10-26T17:09:49-04:00",
448
+ "ClosedDateTime": "",
449
+ "LocationComment": "200 Bono Dr",
450
+ }
451
+ },
452
+ {
453
+ departmentId,
454
+ "incidentNumber": "DEMO-RTS-0003",
455
+ "createdAt": new Date("2022-10-26T22:03:10.401+0000"),
456
+ "payload": {
457
+ "AgencyID": "Demo RTS AgencyId",
458
+ "IncidentNumber": "DEMO-RTS-0003",
459
+ "EntryDateTime": "2022-10-26T17:09:49-04:00",
460
+ "ClosedDateTime": "",
461
+ "CommonPlaceName": "West Housing",
462
+ }
463
+ },
414
464
  // Jackson County
415
465
  {
416
466
  departmentId: departmentJacksonCountyTest._id.toString(),
@@ -876,27 +926,28 @@ export default function({
876
926
  process.exit(1);
877
927
  }
878
928
 
879
- const items: Collection[] = await mongoose.connection.db.collections();
880
- await flushCollections(items, 0);
929
+ await flushCollections();
881
930
  // await mongoose.connection.db.dropDatabase();
882
931
  await prepareTestData();
883
932
  }
884
933
 
885
- async function flushCollections(items: Collection[], index: number) {
886
- if (index >= items.length) {
887
- return;
934
+ async function flushCollections() {
935
+ const modelNames = mongoose.modelNames();
936
+ for (const modelName of modelNames) {
937
+ // debug(`Model ${modelName}`);
938
+ const m = mongoose.model(modelName);
939
+ await m.deleteMany({});
940
+ try {
941
+ await m.syncIndexes();
942
+ } catch (error) {
943
+ console.log(`Failed to sync index ${modelName}`);
944
+ console.error(error);
945
+ process.exit(1);
946
+ }
888
947
  }
889
-
890
- const collection = items[index];
891
- // console.log(`Emptying ${collection.collectionName}.`);
892
- await collection.deleteMany({});
893
- await flushCollections(items, index + 1);
894
948
  }
895
949
 
896
950
  async function prepareTestData() {
897
- // Create indexes
898
- await models.CADIncident.createIndexes();
899
-
900
951
  for (const item of [
901
952
  departmentAlameda,
902
953
  departmentCalfireLNU,
@@ -6,12 +6,14 @@ import {
6
6
  } from "../../rules/set-common-place-name";
7
7
 
8
8
  describe("IncidentRuleSetCommonPlaceName", function describeFunc() {
9
- it("sets common place name", function() {
9
+ it("if both are present, LocationComment - CommonPlaceName is copied to CommonPlaceName", function() {
10
10
  const LocationComment = "1700 Botelho Dr";
11
+ const CommonPlaceName = "SAC HOUSING";
11
12
  const testMatchIncidentWithAddress = {
12
13
  IncidentNumber: "i1238",
13
14
  departmentId: "515",
14
15
  LocationComment,
16
+ CommonPlaceName,
15
17
  };
16
18
 
17
19
  const dateStr = "2022-12-08T11:53:42.000Z";
@@ -20,6 +22,8 @@ describe("IncidentRuleSetCommonPlaceName", function describeFunc() {
20
22
  const result = rule.apply(testMatchIncidentWithAddress, atDate);
21
23
  assert.isTrue(rule.matched);
22
24
  assert.isTrue(rule.changed);
23
- assert.equal(result.CommonPlaceName, LocationComment);
25
+ assert.equal(result.CommonPlaceName, CommonPlaceName);
26
+ assert.equal(result.CommonPlaceNameCopy, CommonPlaceName);
27
+ assert.equal(result.LocationComment, LocationComment);
24
28
  });
25
29
  });
package/.eslintrc.js DELETED
@@ -1,46 +0,0 @@
1
- module.exports = {
2
- env: {
3
- es6: true,
4
- node: true,
5
- mocha: true
6
- },
7
- extends: [
8
- "eslint:recommended",
9
- "plugin:@typescript-eslint/recommended",
10
- "plugin:@typescript-eslint/recommended-requiring-type-checking"
11
- ],
12
- ignorePatterns: [
13
- ".eslintrc.js",
14
- "gulpfile.js",
15
- // Ignore JS files not converted yet
16
- "src/ruleProcessorLegacy.js",
17
- "src/ruleLegacy/*.js",
18
- "src/test/rulesLegacyCleanupCommentsFilters.js",
19
- "src/test/rulesLegacy.js",
20
- ],
21
- plugins: [
22
- "@typescript-eslint",
23
- "promise",
24
- "security"
25
- ],
26
- parser: "@typescript-eslint/parser",
27
- parserOptions: {
28
- project: "./src/tsconfig.json",
29
- tsconfigRootDir: __dirname,
30
- },
31
- rules: {
32
- quotes: [2, "double"],
33
- semi: [2, "always"],
34
- "space-before-function-paren": [0],
35
- "@typescript-eslint/explicit-module-boundary-types": 0,
36
- "@typescript-eslint/no-empty-interface": 0,
37
- "@typescript-eslint/require-await": 0,
38
- "@typescript-eslint/restrict-template-expressions": 0,
39
- "@typescript-eslint/no-misused-promises": [
40
- "error",
41
- {
42
- "checksVoidReturn": false
43
- }
44
- ]
45
- }
46
- };