@cumulus/db 19.0.0 → 19.2.0-alpha.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.
- package/dist/index.d.ts +11 -4
- package/dist/index.js +21 -6
- package/dist/lib/QuerySearchClient.d.ts +0 -2
- package/dist/lib/QuerySearchClient.js +0 -2
- package/dist/lib/collection.d.ts +8 -0
- package/dist/lib/collection.js +36 -1
- package/dist/lib/execution.js +13 -6
- package/dist/lib/granule.d.ts +13 -17
- package/dist/lib/granule.js +22 -24
- package/dist/migrations/20210727104740_alter_async_operations_table_operation_type.js +2 -0
- package/dist/migrations/20240322161147_alter_async_operations_table_operation_type.js +2 -0
- package/dist/migrations/20240606060726_alter_async_operations_add_operation_type_bulk_execution_delete.js +2 -0
- package/dist/migrations/20240814185217_create_reconciliation_reports_table.d.ts +4 -0
- package/dist/migrations/20240814185217_create_reconciliation_reports_table.js +40 -0
- package/dist/models/reconciliation_report.d.ts +10 -0
- package/dist/models/reconciliation_report.js +25 -0
- package/dist/search/AsyncOperationSearch.d.ts +32 -0
- package/dist/search/AsyncOperationSearch.js +55 -0
- package/dist/search/BaseSearch.d.ts +8 -2
- package/dist/search/BaseSearch.js +40 -13
- package/dist/search/CollectionSearch.d.ts +0 -10
- package/dist/search/CollectionSearch.js +3 -17
- package/dist/search/ExecutionSearch.js +3 -4
- package/dist/search/GranuleSearch.d.ts +0 -5
- package/dist/search/GranuleSearch.js +2 -3
- package/dist/search/PdrSearch.d.ts +50 -0
- package/dist/search/PdrSearch.js +100 -0
- package/dist/search/ProviderSearch.d.ts +32 -0
- package/dist/search/ProviderSearch.js +57 -0
- package/dist/search/ReconciliationReportSearch.d.ts +42 -0
- package/dist/search/ReconciliationReportSearch.js +72 -0
- package/dist/search/RuleSearch.d.ts +49 -0
- package/dist/search/RuleSearch.js +95 -0
- package/dist/search/StatsSearch.js +2 -1
- package/dist/search/field-mapping.js +105 -1
- package/dist/search/queries.js +4 -2
- package/dist/tables.d.ts +1 -0
- package/dist/tables.js +1 -0
- package/dist/test-utils.d.ts +3 -17
- package/dist/test-utils.js +10 -1
- package/dist/translate/pdr.d.ts +19 -0
- package/dist/translate/pdr.js +36 -19
- package/dist/translate/reconciliation_reports.d.ts +17 -0
- package/dist/translate/reconciliation_reports.js +36 -0
- package/dist/translate/rules.d.ts +3 -0
- package/dist/translate/rules.js +16 -12
- package/dist/types/reconciliation_report.d.ts +29 -0
- package/dist/types/reconciliation_report.js +3 -0
- package/dist/types/search.d.ts +3 -2
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Knex } from 'knex';
|
|
2
|
-
export { createTestDatabase, deleteTestDatabase, destroyLocalTestDb, fakeAsyncOperationRecordFactory, fakeCollectionRecordFactory, fakeExecutionRecordFactory, fakeFileRecordFactory, fakeGranuleRecordFactory, fakePdrRecordFactory, fakeProviderRecordFactory, fakeRuleRecordFactory, generateLocalTestDb, } from './test-utils';
|
|
2
|
+
export { createTestDatabase, deleteTestDatabase, destroyLocalTestDb, fakeAsyncOperationRecordFactory, fakeCollectionRecordFactory, fakeExecutionRecordFactory, fakeFileRecordFactory, fakeGranuleRecordFactory, fakePdrRecordFactory, fakeProviderRecordFactory, fakeReconciliationReportRecordFactory, fakeRuleRecordFactory, generateLocalTestDb, } from './test-utils';
|
|
3
3
|
export { isCollisionError } from './lib/errors';
|
|
4
4
|
export { getKnexClient } from './connection';
|
|
5
5
|
export { getKnexConfig, localStackConnectionEnv } from './config';
|
|
@@ -17,6 +17,7 @@ export { PostgresGranule, PostgresGranuleRecord, } from './types/granule';
|
|
|
17
17
|
export { PostgresPdr, PostgresPdrRecord, } from './types/pdr';
|
|
18
18
|
export { PostgresFile, PostgresFileRecord, } from './types/file';
|
|
19
19
|
export { PostgresGranuleExecution, } from './types/granule-execution';
|
|
20
|
+
export { PostgresReconciliationReport, PostgresReconciliationReportRecord, } from './types/reconciliation_report';
|
|
20
21
|
export { translateApiAsyncOperationToPostgresAsyncOperation, translatePostgresAsyncOperationToApiAsyncOperation, } from './translate/async_operations';
|
|
21
22
|
export { translateApiFiletoPostgresFile, translatePostgresFileToApiFile, } from './translate/file';
|
|
22
23
|
export { translateApiCollectionToPostgresCollection, translatePostgresCollectionToApiCollection, } from './translate/collections';
|
|
@@ -25,16 +26,21 @@ export { translatePostgresRuleToApiRule, translateApiRuleToPostgresRule, transla
|
|
|
25
26
|
export { translateApiExecutionToPostgresExecution, translateApiExecutionToPostgresExecutionWithoutNilsRemoved, translatePostgresExecutionToApiExecution, } from './translate/executions';
|
|
26
27
|
export { translateApiGranuleToPostgresGranule, translateApiGranuleToPostgresGranuleWithoutNilsRemoved, translatePostgresGranuleToApiGranule, translatePostgresGranuleResultToApiGranule, } from './translate/granules';
|
|
27
28
|
export { translateApiPdrToPostgresPdr, translatePostgresPdrToApiPdr, } from './translate/pdr';
|
|
28
|
-
export {
|
|
29
|
+
export { translateApiReconReportToPostgresReconReport, translatePostgresReconReportToApiReconReport, } from './translate/reconciliation_reports';
|
|
30
|
+
export { getCollectionsByGranuleIds, getUniqueCollectionsByGranuleFilter, } from './lib/collection';
|
|
29
31
|
export { batchDeleteExecutionFromDatabaseByCumulusCollectionId, executionArnsFromGranuleIdsAndWorkflowNames, getApiExecutionCumulusIds, getApiGranuleExecutionCumulusIdsByExecution, getExecutionInfoByGranuleCumulusId, getWorkflowNameIntersectFromGranuleIds, newestExecutionArnFromGranuleIdWorkflowName, } from './lib/execution';
|
|
30
32
|
export { getFilesAndGranuleInfoQuery, } from './lib/file';
|
|
31
33
|
export { getApiGranuleCumulusIds, getApiGranuleExecutionCumulusIds, getGranuleCollectionId, getUniqueGranuleByGranuleId, getGranuleByUniqueColumns, upsertGranuleWithExecutionJoinRecord, getGranulesByApiPropertiesQuery, getGranulesByGranuleId, getGranuleAndCollection, } from './lib/granule';
|
|
32
34
|
export { QuerySearchClient, } from './lib/QuerySearchClient';
|
|
33
|
-
export {
|
|
35
|
+
export { AsyncOperationSearch, } from './search/AsyncOperationSearch';
|
|
36
|
+
export { CollectionSearch, } from './search/CollectionSearch';
|
|
34
37
|
export { ExecutionSearch, } from './search/ExecutionSearch';
|
|
35
38
|
export { GranuleSearch, } from './search/GranuleSearch';
|
|
39
|
+
export { PdrSearch, } from './search/PdrSearch';
|
|
40
|
+
export { ProviderSearch, } from './search/ProviderSearch';
|
|
41
|
+
export { RuleSearch, } from './search/RuleSearch';
|
|
36
42
|
export { StatsSearch, } from './search/StatsSearch';
|
|
37
|
-
export {
|
|
43
|
+
export { ReconciliationReportSearch, } from './search/ReconciliationReportSearch';
|
|
38
44
|
export { AsyncOperationPgModel } from './models/async_operation';
|
|
39
45
|
export { BasePgModel } from './models/base';
|
|
40
46
|
export { CollectionPgModel } from './models/collection';
|
|
@@ -44,5 +50,6 @@ export { GranulePgModel } from './models/granule';
|
|
|
44
50
|
export { GranulesExecutionsPgModel } from './models/granules-executions';
|
|
45
51
|
export { PdrPgModel } from './models/pdr';
|
|
46
52
|
export { ProviderPgModel } from './models/provider';
|
|
53
|
+
export { ReconciliationReportPgModel } from './models/reconciliation_report';
|
|
47
54
|
export { RulePgModel } from './models/rule';
|
|
48
55
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.RulePgModel = exports.ProviderPgModel = exports.PdrPgModel = exports.GranulesExecutionsPgModel = exports.GranulePgModel = exports.FilePgModel = exports.ExecutionPgModel = exports.CollectionPgModel = exports.BasePgModel = exports.AsyncOperationPgModel = exports.
|
|
26
|
+
exports.getApiExecutionCumulusIds = exports.executionArnsFromGranuleIdsAndWorkflowNames = exports.batchDeleteExecutionFromDatabaseByCumulusCollectionId = exports.getUniqueCollectionsByGranuleFilter = exports.getCollectionsByGranuleIds = exports.translatePostgresReconReportToApiReconReport = exports.translateApiReconReportToPostgresReconReport = exports.translatePostgresPdrToApiPdr = exports.translateApiPdrToPostgresPdr = exports.translatePostgresGranuleResultToApiGranule = exports.translatePostgresGranuleToApiGranule = exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = exports.translateApiGranuleToPostgresGranule = exports.translatePostgresExecutionToApiExecution = exports.translateApiExecutionToPostgresExecutionWithoutNilsRemoved = exports.translateApiExecutionToPostgresExecution = exports.translateApiRuleToPostgresRuleRaw = exports.translateApiRuleToPostgresRule = exports.translatePostgresRuleToApiRule = exports.translatePostgresProviderToApiProvider = exports.translateApiProviderToPostgresProvider = exports.translatePostgresCollectionToApiCollection = exports.translateApiCollectionToPostgresCollection = exports.translatePostgresFileToApiFile = exports.translateApiFiletoPostgresFile = exports.translatePostgresAsyncOperationToApiAsyncOperation = exports.translateApiAsyncOperationToPostgresAsyncOperation = exports.nullifyUndefinedProviderValues = exports.validateProviderHost = exports.migrationDir = exports.TableNames = exports.createRejectableTransaction = exports.localStackConnectionEnv = exports.getKnexConfig = exports.getKnexClient = exports.isCollisionError = exports.generateLocalTestDb = exports.fakeRuleRecordFactory = exports.fakeReconciliationReportRecordFactory = exports.fakeProviderRecordFactory = exports.fakePdrRecordFactory = exports.fakeGranuleRecordFactory = exports.fakeFileRecordFactory = exports.fakeExecutionRecordFactory = exports.fakeCollectionRecordFactory = exports.fakeAsyncOperationRecordFactory = exports.destroyLocalTestDb = exports.deleteTestDatabase = exports.createTestDatabase = exports.Knex = void 0;
|
|
27
|
+
exports.RulePgModel = exports.ReconciliationReportPgModel = exports.ProviderPgModel = exports.PdrPgModel = exports.GranulesExecutionsPgModel = exports.GranulePgModel = exports.FilePgModel = exports.ExecutionPgModel = exports.CollectionPgModel = exports.BasePgModel = exports.AsyncOperationPgModel = exports.ReconciliationReportSearch = exports.StatsSearch = exports.RuleSearch = exports.ProviderSearch = exports.PdrSearch = exports.GranuleSearch = exports.ExecutionSearch = exports.CollectionSearch = exports.AsyncOperationSearch = exports.QuerySearchClient = exports.getGranuleAndCollection = exports.getGranulesByGranuleId = exports.getGranulesByApiPropertiesQuery = exports.upsertGranuleWithExecutionJoinRecord = exports.getGranuleByUniqueColumns = exports.getUniqueGranuleByGranuleId = exports.getGranuleCollectionId = exports.getApiGranuleExecutionCumulusIds = exports.getApiGranuleCumulusIds = exports.getFilesAndGranuleInfoQuery = exports.newestExecutionArnFromGranuleIdWorkflowName = exports.getWorkflowNameIntersectFromGranuleIds = exports.getExecutionInfoByGranuleCumulusId = exports.getApiGranuleExecutionCumulusIdsByExecution = void 0;
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
var knex_1 = require("knex");
|
|
30
30
|
Object.defineProperty(exports, "Knex", { enumerable: true, get: function () { return knex_1.Knex; } });
|
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "fakeFileRecordFactory", { enumerable: true, get:
|
|
|
39
39
|
Object.defineProperty(exports, "fakeGranuleRecordFactory", { enumerable: true, get: function () { return test_utils_1.fakeGranuleRecordFactory; } });
|
|
40
40
|
Object.defineProperty(exports, "fakePdrRecordFactory", { enumerable: true, get: function () { return test_utils_1.fakePdrRecordFactory; } });
|
|
41
41
|
Object.defineProperty(exports, "fakeProviderRecordFactory", { enumerable: true, get: function () { return test_utils_1.fakeProviderRecordFactory; } });
|
|
42
|
+
Object.defineProperty(exports, "fakeReconciliationReportRecordFactory", { enumerable: true, get: function () { return test_utils_1.fakeReconciliationReportRecordFactory; } });
|
|
42
43
|
Object.defineProperty(exports, "fakeRuleRecordFactory", { enumerable: true, get: function () { return test_utils_1.fakeRuleRecordFactory; } });
|
|
43
44
|
Object.defineProperty(exports, "generateLocalTestDb", { enumerable: true, get: function () { return test_utils_1.generateLocalTestDb; } });
|
|
44
45
|
var errors_1 = require("./lib/errors");
|
|
@@ -84,8 +85,12 @@ Object.defineProperty(exports, "translatePostgresGranuleResultToApiGranule", { e
|
|
|
84
85
|
var pdr_1 = require("./translate/pdr");
|
|
85
86
|
Object.defineProperty(exports, "translateApiPdrToPostgresPdr", { enumerable: true, get: function () { return pdr_1.translateApiPdrToPostgresPdr; } });
|
|
86
87
|
Object.defineProperty(exports, "translatePostgresPdrToApiPdr", { enumerable: true, get: function () { return pdr_1.translatePostgresPdrToApiPdr; } });
|
|
88
|
+
var reconciliation_reports_1 = require("./translate/reconciliation_reports");
|
|
89
|
+
Object.defineProperty(exports, "translateApiReconReportToPostgresReconReport", { enumerable: true, get: function () { return reconciliation_reports_1.translateApiReconReportToPostgresReconReport; } });
|
|
90
|
+
Object.defineProperty(exports, "translatePostgresReconReportToApiReconReport", { enumerable: true, get: function () { return reconciliation_reports_1.translatePostgresReconReportToApiReconReport; } });
|
|
87
91
|
var collection_1 = require("./lib/collection");
|
|
88
92
|
Object.defineProperty(exports, "getCollectionsByGranuleIds", { enumerable: true, get: function () { return collection_1.getCollectionsByGranuleIds; } });
|
|
93
|
+
Object.defineProperty(exports, "getUniqueCollectionsByGranuleFilter", { enumerable: true, get: function () { return collection_1.getUniqueCollectionsByGranuleFilter; } });
|
|
89
94
|
var execution_1 = require("./lib/execution");
|
|
90
95
|
Object.defineProperty(exports, "batchDeleteExecutionFromDatabaseByCumulusCollectionId", { enumerable: true, get: function () { return execution_1.batchDeleteExecutionFromDatabaseByCumulusCollectionId; } });
|
|
91
96
|
Object.defineProperty(exports, "executionArnsFromGranuleIdsAndWorkflowNames", { enumerable: true, get: function () { return execution_1.executionArnsFromGranuleIdsAndWorkflowNames; } });
|
|
@@ -108,16 +113,24 @@ Object.defineProperty(exports, "getGranulesByGranuleId", { enumerable: true, get
|
|
|
108
113
|
Object.defineProperty(exports, "getGranuleAndCollection", { enumerable: true, get: function () { return granule_1.getGranuleAndCollection; } });
|
|
109
114
|
var QuerySearchClient_1 = require("./lib/QuerySearchClient");
|
|
110
115
|
Object.defineProperty(exports, "QuerySearchClient", { enumerable: true, get: function () { return QuerySearchClient_1.QuerySearchClient; } });
|
|
111
|
-
var
|
|
112
|
-
Object.defineProperty(exports, "
|
|
116
|
+
var AsyncOperationSearch_1 = require("./search/AsyncOperationSearch");
|
|
117
|
+
Object.defineProperty(exports, "AsyncOperationSearch", { enumerable: true, get: function () { return AsyncOperationSearch_1.AsyncOperationSearch; } });
|
|
118
|
+
var CollectionSearch_1 = require("./search/CollectionSearch");
|
|
119
|
+
Object.defineProperty(exports, "CollectionSearch", { enumerable: true, get: function () { return CollectionSearch_1.CollectionSearch; } });
|
|
113
120
|
var ExecutionSearch_1 = require("./search/ExecutionSearch");
|
|
114
121
|
Object.defineProperty(exports, "ExecutionSearch", { enumerable: true, get: function () { return ExecutionSearch_1.ExecutionSearch; } });
|
|
115
122
|
var GranuleSearch_1 = require("./search/GranuleSearch");
|
|
116
123
|
Object.defineProperty(exports, "GranuleSearch", { enumerable: true, get: function () { return GranuleSearch_1.GranuleSearch; } });
|
|
124
|
+
var PdrSearch_1 = require("./search/PdrSearch");
|
|
125
|
+
Object.defineProperty(exports, "PdrSearch", { enumerable: true, get: function () { return PdrSearch_1.PdrSearch; } });
|
|
126
|
+
var ProviderSearch_1 = require("./search/ProviderSearch");
|
|
127
|
+
Object.defineProperty(exports, "ProviderSearch", { enumerable: true, get: function () { return ProviderSearch_1.ProviderSearch; } });
|
|
128
|
+
var RuleSearch_1 = require("./search/RuleSearch");
|
|
129
|
+
Object.defineProperty(exports, "RuleSearch", { enumerable: true, get: function () { return RuleSearch_1.RuleSearch; } });
|
|
117
130
|
var StatsSearch_1 = require("./search/StatsSearch");
|
|
118
131
|
Object.defineProperty(exports, "StatsSearch", { enumerable: true, get: function () { return StatsSearch_1.StatsSearch; } });
|
|
119
|
-
var
|
|
120
|
-
Object.defineProperty(exports, "
|
|
132
|
+
var ReconciliationReportSearch_1 = require("./search/ReconciliationReportSearch");
|
|
133
|
+
Object.defineProperty(exports, "ReconciliationReportSearch", { enumerable: true, get: function () { return ReconciliationReportSearch_1.ReconciliationReportSearch; } });
|
|
121
134
|
var async_operation_1 = require("./models/async_operation");
|
|
122
135
|
Object.defineProperty(exports, "AsyncOperationPgModel", { enumerable: true, get: function () { return async_operation_1.AsyncOperationPgModel; } });
|
|
123
136
|
var base_1 = require("./models/base");
|
|
@@ -136,6 +149,8 @@ var pdr_2 = require("./models/pdr");
|
|
|
136
149
|
Object.defineProperty(exports, "PdrPgModel", { enumerable: true, get: function () { return pdr_2.PdrPgModel; } });
|
|
137
150
|
var provider_2 = require("./models/provider");
|
|
138
151
|
Object.defineProperty(exports, "ProviderPgModel", { enumerable: true, get: function () { return provider_2.ProviderPgModel; } });
|
|
152
|
+
var reconciliation_report_1 = require("./models/reconciliation_report");
|
|
153
|
+
Object.defineProperty(exports, "ReconciliationReportPgModel", { enumerable: true, get: function () { return reconciliation_report_1.ReconciliationReportPgModel; } });
|
|
139
154
|
var rule_1 = require("./models/rule");
|
|
140
155
|
Object.defineProperty(exports, "RulePgModel", { enumerable: true, get: function () { return rule_1.RulePgModel; } });
|
|
141
156
|
//# sourceMappingURL=index.js.map
|
|
@@ -22,13 +22,11 @@ declare class QuerySearchClient<RecordType extends BaseRecord> {
|
|
|
22
22
|
*
|
|
23
23
|
* This does not remove the object from the queue.
|
|
24
24
|
*
|
|
25
|
-
* @returns {Promise<RecordType>} - record from PostgreSQL table
|
|
26
25
|
*/
|
|
27
26
|
peek(): Promise<RecordType>;
|
|
28
27
|
/**
|
|
29
28
|
* Remove and return the next item in the results
|
|
30
29
|
*
|
|
31
|
-
* @returns {Promise<RecordType>} - record from PostgreSQL table
|
|
32
30
|
*/
|
|
33
31
|
shift(): Promise<RecordType | undefined>;
|
|
34
32
|
}
|
|
@@ -30,7 +30,6 @@ class QuerySearchClient {
|
|
|
30
30
|
*
|
|
31
31
|
* This does not remove the object from the queue.
|
|
32
32
|
*
|
|
33
|
-
* @returns {Promise<RecordType>} - record from PostgreSQL table
|
|
34
33
|
*/
|
|
35
34
|
async peek() {
|
|
36
35
|
if (this.records.length === 0)
|
|
@@ -40,7 +39,6 @@ class QuerySearchClient {
|
|
|
40
39
|
/**
|
|
41
40
|
* Remove and return the next item in the results
|
|
42
41
|
*
|
|
43
|
-
* @returns {Promise<RecordType>} - record from PostgreSQL table
|
|
44
42
|
*/
|
|
45
43
|
async shift() {
|
|
46
44
|
if (this.records.length === 0)
|
package/dist/lib/collection.d.ts
CHANGED
|
@@ -7,4 +7,12 @@ import { Knex } from 'knex';
|
|
|
7
7
|
* @returns {Promise<Array<Object>>} - An array of collection results
|
|
8
8
|
*/
|
|
9
9
|
export declare const getCollectionsByGranuleIds: (knex: Knex, granuleIds: string[]) => Promise<never>;
|
|
10
|
+
export declare const getUniqueCollectionsByGranuleFilter: (params: {
|
|
11
|
+
startTimestamp?: string;
|
|
12
|
+
endTimestamp?: string;
|
|
13
|
+
collectionIds?: string[];
|
|
14
|
+
granuleIds?: string[];
|
|
15
|
+
providers?: string[];
|
|
16
|
+
knex: Knex;
|
|
17
|
+
}) => Promise<any[]>;
|
|
10
18
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/lib/collection.js
CHANGED
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getCollectionsByGranuleIds = void 0;
|
|
6
|
+
exports.getUniqueCollectionsByGranuleFilter = exports.getCollectionsByGranuleIds = void 0;
|
|
7
7
|
const logger_1 = __importDefault(require("@cumulus/logger"));
|
|
8
|
+
const Collections_1 = require("@cumulus/message/Collections");
|
|
8
9
|
const retry_1 = require("./retry");
|
|
9
10
|
const tables_1 = require("../tables");
|
|
10
11
|
/**
|
|
@@ -25,4 +26,38 @@ const getCollectionsByGranuleIds = async (knex, granuleIds) => {
|
|
|
25
26
|
return await (0, retry_1.RetryOnDbConnectionTerminateError)(query, {}, log);
|
|
26
27
|
};
|
|
27
28
|
exports.getCollectionsByGranuleIds = getCollectionsByGranuleIds;
|
|
29
|
+
// TODO - This function is going to be super-non-performant
|
|
30
|
+
// We need to identify the specific need here and see if we can optimize
|
|
31
|
+
const getUniqueCollectionsByGranuleFilter = async (params) => {
|
|
32
|
+
const { knex } = params;
|
|
33
|
+
const collectionsTable = tables_1.TableNames.collections;
|
|
34
|
+
const granulesTable = tables_1.TableNames.granules;
|
|
35
|
+
const providersTable = tables_1.TableNames.providers;
|
|
36
|
+
const query = knex(collectionsTable)
|
|
37
|
+
.distinct(`${collectionsTable}.*`)
|
|
38
|
+
.innerJoin(granulesTable, `${collectionsTable}.cumulus_id`, `${granulesTable}.collection_cumulus_id`);
|
|
39
|
+
if (params.startTimestamp) {
|
|
40
|
+
query.where(`${granulesTable}.updated_at`, '>=', params.startTimestamp);
|
|
41
|
+
}
|
|
42
|
+
if (params.endTimestamp) {
|
|
43
|
+
query.where(`${granulesTable}.updated_at`, '<=', params.endTimestamp);
|
|
44
|
+
}
|
|
45
|
+
// Filter by collectionIds
|
|
46
|
+
if (params.collectionIds && params.collectionIds.length > 0) {
|
|
47
|
+
const collectionNameVersionPairs = params.collectionIds.map((id) => (0, Collections_1.deconstructCollectionId)(id));
|
|
48
|
+
query.whereIn([`${collectionsTable}.name`, `${collectionsTable}.version`], collectionNameVersionPairs.map(({ name, version }) => [name, version]));
|
|
49
|
+
}
|
|
50
|
+
// Filter by granuleIds
|
|
51
|
+
if (params.granuleIds && params.granuleIds.length > 0) {
|
|
52
|
+
query.whereIn(`${granulesTable}.granule_id`, params.granuleIds);
|
|
53
|
+
}
|
|
54
|
+
// Filter by provider names
|
|
55
|
+
if (params.providers && params.providers.length > 0) {
|
|
56
|
+
query.innerJoin(providersTable, `${granulesTable}.provider_cumulus_id`, `${providersTable}.cumulus_id`);
|
|
57
|
+
query.whereIn(`${providersTable}.name`, params.providers);
|
|
58
|
+
}
|
|
59
|
+
query.orderBy([`${collectionsTable}.name`, `${collectionsTable}.version`]);
|
|
60
|
+
return query;
|
|
61
|
+
};
|
|
62
|
+
exports.getUniqueCollectionsByGranuleFilter = getUniqueCollectionsByGranuleFilter;
|
|
28
63
|
//# sourceMappingURL=collection.js.map
|
package/dist/lib/execution.js
CHANGED
|
@@ -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.
|
|
127
|
-
.orderBy('timestamp', 'desc');
|
|
126
|
+
queryBuilder.min('timestamp');
|
|
128
127
|
}
|
|
129
128
|
});
|
|
130
|
-
|
|
131
|
-
|
|
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
|
/**
|
package/dist/lib/granule.d.ts
CHANGED
|
@@ -79,24 +79,20 @@ export declare const getApiGranuleExecutionCumulusIds: (knexOrTransaction: Knex
|
|
|
79
79
|
}>, collectionPgModel?: CollectionPgModel, granulePgModel?: GranulePgModel, granulesExecutionsPgModel?: GranulesExecutionsPgModel) => Promise<Array<number>>;
|
|
80
80
|
/**
|
|
81
81
|
* Helper to build a query to search granules by various API granule record properties.
|
|
82
|
-
*
|
|
83
|
-
* @param {Knex} knex - DB client
|
|
84
|
-
* @param {Object} searchParams
|
|
85
|
-
* @param {string | Array<string>} [searchParams.collectionIds] - Collection ID
|
|
86
|
-
* @param {string | Array<string>} [searchParams.granuleIds] - array of granule IDs
|
|
87
|
-
* @param {string} [searchParams.providerNames] - Provider names
|
|
88
|
-
* @param {UpdatedAtRange} [searchParams.updatedAtRange] - Date range for updated_at column
|
|
89
|
-
* @param {string} [searchParams.status] - Granule status to search by
|
|
90
|
-
* @param {string | Array<string>} [sortByFields] - Field(s) to sort by
|
|
91
|
-
* @returns {Knex.QueryBuilder}
|
|
92
82
|
*/
|
|
93
|
-
export declare const getGranulesByApiPropertiesQuery: (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
export declare const getGranulesByApiPropertiesQuery: ({ knex, searchParams, sortByFields, temporalBoundByCreatedAt, }: {
|
|
84
|
+
knex: Knex;
|
|
85
|
+
searchParams: {
|
|
86
|
+
collate?: string;
|
|
87
|
+
collectionIds?: string | string[];
|
|
88
|
+
granuleIds?: string | string[];
|
|
89
|
+
providerNames?: string[];
|
|
90
|
+
status?: string;
|
|
91
|
+
updatedAtRange?: UpdatedAtRange;
|
|
92
|
+
};
|
|
93
|
+
sortByFields?: string | string[] | undefined;
|
|
94
|
+
temporalBoundByCreatedAt?: boolean | undefined;
|
|
95
|
+
}) => Knex.QueryBuilder;
|
|
100
96
|
/**
|
|
101
97
|
* Get Postgres Granule and Collection objects for a granuleId + collectionId
|
|
102
98
|
*
|
package/dist/lib/granule.js
CHANGED
|
@@ -138,19 +138,10 @@ const getApiGranuleExecutionCumulusIds = async (knexOrTransaction, granules, col
|
|
|
138
138
|
exports.getApiGranuleExecutionCumulusIds = getApiGranuleExecutionCumulusIds;
|
|
139
139
|
/**
|
|
140
140
|
* Helper to build a query to search granules by various API granule record properties.
|
|
141
|
-
*
|
|
142
|
-
* @param {Knex} knex - DB client
|
|
143
|
-
* @param {Object} searchParams
|
|
144
|
-
* @param {string | Array<string>} [searchParams.collectionIds] - Collection ID
|
|
145
|
-
* @param {string | Array<string>} [searchParams.granuleIds] - array of granule IDs
|
|
146
|
-
* @param {string} [searchParams.providerNames] - Provider names
|
|
147
|
-
* @param {UpdatedAtRange} [searchParams.updatedAtRange] - Date range for updated_at column
|
|
148
|
-
* @param {string} [searchParams.status] - Granule status to search by
|
|
149
|
-
* @param {string | Array<string>} [sortByFields] - Field(s) to sort by
|
|
150
|
-
* @returns {Knex.QueryBuilder}
|
|
151
141
|
*/
|
|
152
|
-
const getGranulesByApiPropertiesQuery = (
|
|
142
|
+
const getGranulesByApiPropertiesQuery = ({ knex, searchParams, sortByFields = [], temporalBoundByCreatedAt = false, }) => {
|
|
153
143
|
const { granules: granulesTable, collections: collectionsTable, providers: providersTable, } = TableNames;
|
|
144
|
+
const temporalColumn = temporalBoundByCreatedAt ? 'created_at' : 'updated_at';
|
|
154
145
|
return knex(granulesTable)
|
|
155
146
|
.select(`${granulesTable}.*`)
|
|
156
147
|
.select({
|
|
@@ -161,34 +152,41 @@ const getGranulesByApiPropertiesQuery = (knex, { collectionIds, granuleIds, prov
|
|
|
161
152
|
.innerJoin(collectionsTable, `${granulesTable}.collection_cumulus_id`, `${collectionsTable}.cumulus_id`)
|
|
162
153
|
.leftJoin(providersTable, `${granulesTable}.provider_cumulus_id`, `${providersTable}.cumulus_id`)
|
|
163
154
|
.modify((queryBuilder) => {
|
|
164
|
-
if (collectionIds) {
|
|
165
|
-
const collectionIdFilters = [collectionIds].flat();
|
|
155
|
+
if (searchParams.collectionIds) {
|
|
156
|
+
const collectionIdFilters = [searchParams.collectionIds].flat();
|
|
166
157
|
const collectionIdConcatField = `(${collectionsTable}.name || '${Collections_1.collectionIdSeparator}' || ${collectionsTable}.version)`;
|
|
167
158
|
const collectionIdInClause = collectionIdFilters.map(() => '?').join(',');
|
|
168
159
|
queryBuilder.whereRaw(`${collectionIdConcatField} IN (${collectionIdInClause})`, collectionIdFilters);
|
|
169
160
|
}
|
|
170
|
-
if (granuleIds) {
|
|
171
|
-
const granuleIdFilters = [granuleIds].flat();
|
|
161
|
+
if (searchParams.granuleIds) {
|
|
162
|
+
const granuleIdFilters = [searchParams.granuleIds].flat();
|
|
172
163
|
queryBuilder.where((nestedQueryBuilder) => {
|
|
173
164
|
granuleIdFilters.forEach((granuleId) => {
|
|
174
165
|
nestedQueryBuilder.orWhere(`${granulesTable}.granule_id`, 'LIKE', `%${granuleId}%`);
|
|
175
166
|
});
|
|
176
167
|
});
|
|
177
168
|
}
|
|
178
|
-
if (providerNames) {
|
|
179
|
-
queryBuilder.whereIn(`${providersTable}.name`, providerNames);
|
|
169
|
+
if (searchParams.providerNames) {
|
|
170
|
+
queryBuilder.whereIn(`${providersTable}.name`, searchParams.providerNames);
|
|
180
171
|
}
|
|
181
|
-
if (updatedAtRange
|
|
182
|
-
queryBuilder.where(`${granulesTable}
|
|
172
|
+
if (searchParams?.updatedAtRange?.updatedAtFrom) {
|
|
173
|
+
queryBuilder.where(`${granulesTable}.${temporalColumn}`, '>=', searchParams.updatedAtRange.updatedAtFrom);
|
|
183
174
|
}
|
|
184
|
-
if (updatedAtRange
|
|
185
|
-
queryBuilder.where(`${granulesTable}
|
|
175
|
+
if (searchParams?.updatedAtRange?.updatedAtTo) {
|
|
176
|
+
queryBuilder.where(`${granulesTable}.${temporalColumn}`, '<=', searchParams.updatedAtRange.updatedAtTo);
|
|
186
177
|
}
|
|
187
|
-
if (status) {
|
|
188
|
-
queryBuilder.where(`${granulesTable}.status`, status);
|
|
178
|
+
if (searchParams.status) {
|
|
179
|
+
queryBuilder.where(`${granulesTable}.status`, searchParams.status);
|
|
189
180
|
}
|
|
190
181
|
if (sortByFields) {
|
|
191
|
-
|
|
182
|
+
if (!searchParams.collate) {
|
|
183
|
+
queryBuilder.orderBy([sortByFields].flat());
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
[sortByFields].flat().forEach((field) => {
|
|
187
|
+
queryBuilder.orderByRaw(`${field} collate \"${searchParams.collate}\"`);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
192
190
|
}
|
|
193
191
|
})
|
|
194
192
|
.groupBy(`${granulesTable}.cumulus_id`)
|
|
@@ -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
|
]));
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
const up = async (knex) => {
|
|
5
|
+
await knex.schema.createTable('reconciliation_reports', (table) => {
|
|
6
|
+
table
|
|
7
|
+
.increments('cumulus_id')
|
|
8
|
+
.primary();
|
|
9
|
+
table
|
|
10
|
+
.text('name')
|
|
11
|
+
.comment('Reconciliation Report name')
|
|
12
|
+
.notNullable();
|
|
13
|
+
table
|
|
14
|
+
.enum('type', ['Granule Inventory', 'Granule Not Found', 'Internal', 'Inventory', 'ORCA Backup'])
|
|
15
|
+
.comment('Type of Reconciliation Report')
|
|
16
|
+
.notNullable();
|
|
17
|
+
table
|
|
18
|
+
.enum('status', ['Generated', 'Pending', 'Failed'])
|
|
19
|
+
.comment('Status of Reconciliation Report')
|
|
20
|
+
.notNullable();
|
|
21
|
+
table
|
|
22
|
+
.text('location')
|
|
23
|
+
.comment('Location of Reconciliation Report');
|
|
24
|
+
table
|
|
25
|
+
.jsonb('error')
|
|
26
|
+
.comment('Error object');
|
|
27
|
+
// adds "created_at" and "updated_at" columns automatically
|
|
28
|
+
table
|
|
29
|
+
.timestamps(false, true);
|
|
30
|
+
table.index('status');
|
|
31
|
+
table.index('updated_at');
|
|
32
|
+
table.unique(['name']);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.up = up;
|
|
36
|
+
const down = async (knex) => {
|
|
37
|
+
await knex.schema.dropTableIfExists('reconciliation_reports');
|
|
38
|
+
};
|
|
39
|
+
exports.down = down;
|
|
40
|
+
//# sourceMappingURL=20240814185217_create_reconciliation_reports_table.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Knex } from 'knex';
|
|
2
|
+
import { BasePgModel } from './base';
|
|
3
|
+
import { PostgresReconciliationReport, PostgresReconciliationReportRecord } from '../types/reconciliation_report';
|
|
4
|
+
declare class ReconciliationReportPgModel extends BasePgModel<PostgresReconciliationReport, PostgresReconciliationReportRecord> {
|
|
5
|
+
constructor();
|
|
6
|
+
create(knexOrTransaction: Knex | Knex.Transaction, item: PostgresReconciliationReport): Promise<PostgresReconciliationReportRecord[]>;
|
|
7
|
+
upsert(knexOrTransaction: Knex | Knex.Transaction, reconciliationReport: PostgresReconciliationReport): Promise<PostgresReconciliationReportRecord[]>;
|
|
8
|
+
}
|
|
9
|
+
export { ReconciliationReportPgModel };
|
|
10
|
+
//# sourceMappingURL=reconciliation_report.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReconciliationReportPgModel = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const tables_1 = require("../tables");
|
|
6
|
+
// eslint-disable-next-line max-len
|
|
7
|
+
class ReconciliationReportPgModel extends base_1.BasePgModel {
|
|
8
|
+
constructor() {
|
|
9
|
+
super({
|
|
10
|
+
tableName: tables_1.TableNames.reconciliationReports,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
create(knexOrTransaction, item) {
|
|
14
|
+
return super.create(knexOrTransaction, item, '*');
|
|
15
|
+
}
|
|
16
|
+
upsert(knexOrTransaction, reconciliationReport) {
|
|
17
|
+
return knexOrTransaction(this.tableName)
|
|
18
|
+
.insert(reconciliationReport)
|
|
19
|
+
.onConflict('name')
|
|
20
|
+
.merge()
|
|
21
|
+
.returning('*');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ReconciliationReportPgModel = ReconciliationReportPgModel;
|
|
25
|
+
//# sourceMappingURL=reconciliation_report.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Knex } from 'knex';
|
|
2
|
+
import { ApiAsyncOperation } from '@cumulus/types/api/async_operations';
|
|
3
|
+
import { BaseSearch } from './BaseSearch';
|
|
4
|
+
import { DbQueryParameters, QueryEvent } from '../types/search';
|
|
5
|
+
import { PostgresAsyncOperationRecord } from '../types/async_operation';
|
|
6
|
+
/**
|
|
7
|
+
* Class to build and execute db search query for asyncOperation
|
|
8
|
+
*/
|
|
9
|
+
export declare class AsyncOperationSearch extends BaseSearch {
|
|
10
|
+
constructor(event: QueryEvent);
|
|
11
|
+
/**
|
|
12
|
+
* Build queries for infix and prefix
|
|
13
|
+
*
|
|
14
|
+
* @param params
|
|
15
|
+
* @param params.countQuery - query builder for getting count
|
|
16
|
+
* @param params.searchQuery - query builder for search
|
|
17
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
18
|
+
*/
|
|
19
|
+
protected buildInfixPrefixQuery(params: {
|
|
20
|
+
countQuery: Knex.QueryBuilder;
|
|
21
|
+
searchQuery: Knex.QueryBuilder;
|
|
22
|
+
dbQueryParameters?: DbQueryParameters;
|
|
23
|
+
}): void;
|
|
24
|
+
/**
|
|
25
|
+
* Translate postgres records to api records
|
|
26
|
+
*
|
|
27
|
+
* @param pgRecords - postgres records returned from query
|
|
28
|
+
* @returns translated api records
|
|
29
|
+
*/
|
|
30
|
+
protected translatePostgresRecordsToApiRecords(pgRecords: PostgresAsyncOperationRecord[]): Partial<ApiAsyncOperation>[];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=AsyncOperationSearch.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AsyncOperationSearch = void 0;
|
|
7
|
+
const pick_1 = __importDefault(require("lodash/pick"));
|
|
8
|
+
const logger_1 = __importDefault(require("@cumulus/logger"));
|
|
9
|
+
const BaseSearch_1 = require("./BaseSearch");
|
|
10
|
+
const async_operations_1 = require("../translate/async_operations");
|
|
11
|
+
const log = new logger_1.default({ sender: '@cumulus/db/AsyncOperationSearch' });
|
|
12
|
+
/**
|
|
13
|
+
* Class to build and execute db search query for asyncOperation
|
|
14
|
+
*/
|
|
15
|
+
class AsyncOperationSearch extends BaseSearch_1.BaseSearch {
|
|
16
|
+
constructor(event) {
|
|
17
|
+
super(event, 'asyncOperation');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build queries for infix and prefix
|
|
21
|
+
*
|
|
22
|
+
* @param params
|
|
23
|
+
* @param params.countQuery - query builder for getting count
|
|
24
|
+
* @param params.searchQuery - query builder for search
|
|
25
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
26
|
+
*/
|
|
27
|
+
buildInfixPrefixQuery(params) {
|
|
28
|
+
const { countQuery, searchQuery, dbQueryParameters } = params;
|
|
29
|
+
const { infix, prefix } = dbQueryParameters ?? this.dbQueryParameters;
|
|
30
|
+
if (infix) {
|
|
31
|
+
[countQuery, searchQuery].forEach((query) => query.whereRaw(`${this.tableName}.id::text like ?`, `%${infix}%`));
|
|
32
|
+
}
|
|
33
|
+
if (prefix) {
|
|
34
|
+
[countQuery, searchQuery].forEach((query) => query.whereRaw(`${this.tableName}.id::text like ?`, `${prefix}%`));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Translate postgres records to api records
|
|
39
|
+
*
|
|
40
|
+
* @param pgRecords - postgres records returned from query
|
|
41
|
+
* @returns translated api records
|
|
42
|
+
*/
|
|
43
|
+
translatePostgresRecordsToApiRecords(pgRecords) {
|
|
44
|
+
log.debug(`translatePostgresRecordsToApiRecords number of records ${pgRecords.length} `);
|
|
45
|
+
const { fields } = this.dbQueryParameters;
|
|
46
|
+
const apiRecords = pgRecords.map((item) => {
|
|
47
|
+
const pgAsyncOperation = item;
|
|
48
|
+
const apiRecord = (0, async_operations_1.translatePostgresAsyncOperationToApiAsyncOperation)(pgAsyncOperation);
|
|
49
|
+
return fields ? (0, pick_1.default)(apiRecord, fields) : apiRecord;
|
|
50
|
+
});
|
|
51
|
+
return apiRecords;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.AsyncOperationSearch = AsyncOperationSearch;
|
|
55
|
+
//# sourceMappingURL=AsyncOperationSearch.js.map
|
|
@@ -7,7 +7,7 @@ export declare const typeToTable: {
|
|
|
7
7
|
/**
|
|
8
8
|
* Class to build and execute db search query
|
|
9
9
|
*/
|
|
10
|
-
declare class BaseSearch {
|
|
10
|
+
declare abstract class BaseSearch {
|
|
11
11
|
readonly type: string;
|
|
12
12
|
readonly tableName: string;
|
|
13
13
|
readonly queryStringParameters: QueryStringParameters;
|
|
@@ -19,6 +19,12 @@ declare class BaseSearch {
|
|
|
19
19
|
* @returns whether collection search is needed
|
|
20
20
|
*/
|
|
21
21
|
protected searchCollection(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* check if joined executions table search is needed
|
|
24
|
+
*
|
|
25
|
+
* @returns whether execution search is needed
|
|
26
|
+
*/
|
|
27
|
+
protected searchExecution(): boolean;
|
|
22
28
|
/**
|
|
23
29
|
* check if joined pdrs table search is needed
|
|
24
30
|
*
|
|
@@ -58,7 +64,7 @@ declare class BaseSearch {
|
|
|
58
64
|
* Build basic query
|
|
59
65
|
*
|
|
60
66
|
* @param knex - DB client
|
|
61
|
-
* @
|
|
67
|
+
* @returns queries for getting count and search result
|
|
62
68
|
*/
|
|
63
69
|
protected buildBasicQuery(knex: Knex): {
|
|
64
70
|
countQuery?: Knex.QueryBuilder;
|