@cumulus/db 19.0.0 → 19.1.0

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.
@@ -115,20 +115,27 @@ const getWorkflowNameIntersectFromGranuleIds = async (knexOrTransaction, granule
115
115
  const numberOfGranules = granuleCumulusIdsArray.length;
116
116
  const { executions: executionsTable, granulesExecutions: granulesExecutionsTable } = tables_1.TableNames;
117
117
  const aggregatedWorkflowCounts = await knexOrTransaction(executionsTable)
118
- .select('workflow_name')
119
- .countDistinct('granule_cumulus_id')
118
+ .select(['workflow_name'])
120
119
  .innerJoin(granulesExecutionsTable, `${executionsTable}.cumulus_id`, `${granulesExecutionsTable}.execution_cumulus_id`)
121
120
  .whereIn('granule_cumulus_id', granuleCumulusIdsArray)
122
121
  .groupBy('workflow_name')
122
+ .countDistinct('granule_cumulus_id')
123
123
  .havingRaw('count(distinct granule_cumulus_id) = ?', [numberOfGranules])
124
124
  .modify((queryBuilder) => {
125
125
  if (numberOfGranules === 1) {
126
- queryBuilder.groupBy('timestamp')
127
- .orderBy('timestamp', 'desc');
126
+ queryBuilder.min('timestamp');
128
127
  }
129
128
  });
130
- return aggregatedWorkflowCounts
131
- .map((workflowCounts) => workflowCounts.workflow_name);
129
+ /*
130
+ sort (and group by) in knex causes an edge case where two distinct workflows
131
+ of the same name will be returned if they have different timestamps. This means
132
+ different returns depending on whether you have asked for one or multiple granules
133
+ hence this sort has been moved to js logic
134
+ */
135
+ if (numberOfGranules === 1) {
136
+ aggregatedWorkflowCounts.sort((a, b) => b.min - a.min);
137
+ }
138
+ return aggregatedWorkflowCounts.map((workflowCounts) => workflowCounts.workflow_name);
132
139
  };
133
140
  exports.getWorkflowNameIntersectFromGranuleIds = getWorkflowNameIntersectFromGranuleIds;
134
141
  /**
@@ -18,6 +18,7 @@ const up = async (knex) => {
18
18
  'Dead-Letter Processing',
19
19
  'Kinesis Replay',
20
20
  'Reconciliation Report',
21
+ 'Migration Count Report',
21
22
  'Data Migration',
22
23
  'SQS Replay',
23
24
  ]));
@@ -32,6 +33,7 @@ const down = async (knex) => {
32
33
  'Dead-Letter Processing',
33
34
  'Kinesis Replay',
34
35
  'Reconciliation Report',
36
+ 'Migration Count Report',
35
37
  'Data Migration',
36
38
  ]));
37
39
  };
@@ -19,6 +19,7 @@ const up = async (knex) => {
19
19
  'DLA Migration',
20
20
  'Kinesis Replay',
21
21
  'Reconciliation Report',
22
+ 'Migration Count Report',
22
23
  'Data Migration',
23
24
  'SQS Replay',
24
25
  ]));
@@ -33,6 +34,7 @@ const down = async (knex) => {
33
34
  'Dead-Letter Processing',
34
35
  'Kinesis Replay',
35
36
  'Reconciliation Report',
37
+ 'Migration Count Report',
36
38
  'Data Migration',
37
39
  'SQS Replay',
38
40
  ]));
@@ -21,6 +21,7 @@ const up = async (knex) => {
21
21
  'ES Index',
22
22
  'Kinesis Replay',
23
23
  'Reconciliation Report',
24
+ 'Migration Count Report',
24
25
  'SQS Replay',
25
26
  ]));
26
27
  };
@@ -35,6 +36,7 @@ const down = async (knex) => {
35
36
  'DLA Migration',
36
37
  'Kinesis Replay',
37
38
  'Reconciliation Report',
39
+ 'Migration Count Report',
38
40
  'Data Migration',
39
41
  'SQS Replay',
40
42
  ]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulus/db",
3
- "version": "19.0.0",
3
+ "version": "19.1.0",
4
4
  "description": "Utilities for working with the Cumulus DB",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -33,22 +33,22 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@aws-sdk/client-secrets-manager": "^3.621.0",
36
- "@cumulus/aws-client": "19.0.0",
37
- "@cumulus/common": "19.0.0",
38
- "@cumulus/errors": "19.0.0",
39
- "@cumulus/logger": "19.0.0",
40
- "@cumulus/message": "19.0.0",
41
- "@cumulus/types": "19.0.0",
36
+ "@cumulus/aws-client": "19.1.0",
37
+ "@cumulus/common": "19.1.0",
38
+ "@cumulus/errors": "19.1.0",
39
+ "@cumulus/logger": "19.1.0",
40
+ "@cumulus/message": "19.1.0",
41
+ "@cumulus/types": "19.1.0",
42
42
  "crypto-random-string": "^3.2.0",
43
43
  "is-valid-hostname": "1.0.2",
44
44
  "knex": "2.4.1",
45
45
  "lodash": "^4.17.21",
46
- "pg": "~8.10",
46
+ "pg": "~8.13",
47
47
  "snake-camel": "^1.0.6",
48
48
  "uuid": "8.3.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/uuid": "^8.0.0"
52
52
  },
53
- "gitHead": "3a619db6e6fa20846eb75802e89d5a065fd62fcc"
53
+ "gitHead": "803acf8212df5203ec502c5b16dde49a20265b7e"
54
54
  }