Skip to content

Commit 2a91608

Browse files
authored
RELEASE v4.24.5 (#2290)
<!-- Follow semantic-release guidelines for the PR title, which is used in the changelog. Title should follow the format `<type>(<scope>): <subject>`, where - Type is one of: build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|BREAKING CHANGE - Scope (optional) describes the place of the change (eg a particular milestone) and is usually omitted - subject should be a non-capitalized one-line description in present imperative tense and not ending with a period See https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines for more details. --> ## Description <!-- Short description of the pull request --> Creating a release to generate typescript sdk artifiacts, as `OutputDatasetObsoleteDto` and `HistoryClass` (used in the frontend) has changed (OutputDatasetObsoleteDto includes a v3 compatible history field, and HistoryClass includes an index signature #2282) ## Motivation <!-- Background on use case, changes needed --> ## Fixes <!-- Please provide a list of the issues fixed by this PR --> * Bug fixed (#X) ## Changes: <!-- Please provide a list of the changes implemented by this PR --> * changes made ## Tests included - [ ] Included for each change/fix? - [ ] Passing? <!-- Merge will not be approved unless tests pass --> ## Documentation - [ ] swagger documentation updated (required for API changes) - [ ] official documentation updated ### official documentation info <!-- If you have updated the official documentation, please provide PR # and URL of the updated pages -->
2 parents 26ae837 + e1c024a commit 2a91608

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1342
-444
lines changed

migrate-mongo-config.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@ if (!MONGODB_URI) {
55
throw new Error("Environment variable MONGODB_URI not set");
66
}
77

8-
const lastSlashIndex = MONGODB_URI.lastIndexOf("/");
9-
// NOTE: Get the database url and name from the MONGODB_URI and use them instead of defining new variables.
10-
const DATABASE_URL = MONGODB_URI.substring(0, lastSlashIndex);
11-
const DATABASE_NAME = MONGODB_URI.substring(lastSlashIndex + 1);
12-
138
const config = {
149
mongodb: {
15-
url: DATABASE_URL,
16-
17-
databaseName: DATABASE_NAME,
10+
url: MONGODB_URI,
1811

1912
options: {
2013
useNewUrlParser: true, // removes a deprecation warning when connecting
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
2+
const convertObsoleteHistoryToGenericHistory =
3+
require("../dist/datasets/utils/history.util").convertObsoleteHistoryToGenericHistory;
4+
5+
const convertGenericHistoriesToObsoleteHistories =
6+
require("../dist/datasets/utils/history.util").convertGenericHistoriesToObsoleteHistories;
7+
8+
module.exports = {
9+
/**
10+
* @param db {import('mongodb').Db}
11+
* @param client {import('mongodb').MongoClient}
12+
* @returns {Promise<void>}
13+
*/
14+
async up(db, client) {
15+
for await (const dataset of db
16+
.collection("Dataset")
17+
.find({ history: { $exists: true, $type: "array", $ne: [] } })) {
18+
console.log(
19+
`Migrating history for dataset ${dataset._id}. Entries: ${dataset.history.length}`,
20+
);
21+
const genericHistories = dataset.history.map((entry) =>
22+
convertObsoleteHistoryToGenericHistory(entry, dataset._id),
23+
);
24+
result = await db.collection("History").insertMany(genericHistories);
25+
}
26+
await db.collection("Dataset").updateMany({}, { $unset: { history: "" } });
27+
},
28+
29+
/**
30+
* @param db {import('mongodb').Db}
31+
* @param client {import('mongodb').MongoClient}
32+
* @returns {Promise<void>}
33+
*/
34+
async down(db, client) {
35+
for await (const dataset of db
36+
.collection("Dataset")
37+
.find({ history: { $exists: false } })) {
38+
console.log(`Rolling back history for dataset ${dataset._id}`);
39+
const genericHistories = await db
40+
.collection("History")
41+
.find(
42+
{ documentId: dataset._id, subsystem: "Dataset" },
43+
{ sort: { timestamp: "desc" } },
44+
)
45+
.toArray();
46+
console.log(
47+
`Found ${genericHistories.length} history entries for dataset ${dataset._id}`,
48+
);
49+
dataset.$clone = () => dataset; // Mock the $clone method, as this is not a mongoose document
50+
const obsoleteHistories = convertGenericHistoriesToObsoleteHistories(
51+
genericHistories,
52+
dataset,
53+
);
54+
console.log(
55+
`Inserting obsolete history entries for dataset ${dataset._id}`,
56+
);
57+
await db
58+
.collection("Dataset")
59+
.updateOne(
60+
{ _id: dataset._id },
61+
{ $set: { history: obsoleteHistories } },
62+
);
63+
}
64+
},
65+
};

0 commit comments

Comments
 (0)