Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 35bb801

Browse files
authored
Merge pull request #427 from topcoder-platform/develop
Version 1.2
2 parents 8d6fc6d + e1db3ae commit 35bb801

39 files changed

+1838
-350
lines changed

Diff for: TopcoderXDeploy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ You can do this by clicking your logged in username in the upper right of the To
157157

158158
Once you have registered your account, go into `Project Management` and add a new project for either a Gitlab or Github project you have access to. Gitlab is likely easier for testing - you can create a free test project under your own account.
159159

160-
Use Topcoder Connect ID `16665` since this has a valid billing account in the dev environment.
160+
Use Topcoder Connect ID `17249` since this has a valid billing account in the dev environment.
161161

162162
Once it's been added, click `Manage` for the project in the list on `Project Management` and click `Add Webhooks`. Once the webhook has been added, you should be able to see it in the Gitlab project under `Settings` --> `Integrations` --> `Webhooks`
163163

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"create-tables": "CREATE_DB=true node scripts/create-update-tables.js",
2525
"migrate-user-mapping": "node scripts/migrate-user-mapping.js",
2626
"add-organisation": "node scripts/add-organisation.js",
27-
"log-repository-collisions": "node scripts/log-repository-collisions.js"
27+
"log-repository-collisions": "node scripts/log-repository-collisions.js",
28+
"migrate-repo-url": "node scripts/migrate-repo-url.js"
2829
},
2930
"dependencies": {
3031
"angular": "~1.8.0",

Diff for: scripts/log-repository-collisions.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ async function main() {
1717
archived: 'false'
1818
}).consistent().limit(BATCH_SIZE).startAt(previousKey).exec()
1919
for (const project of projects) {
20-
// If url was already found colliding go to a next iteration
21-
if (collidingUrls.includes(project.repoUrl)) continue;
22-
const collisions = await models.Project.scan({
23-
repoUrl: project.repoUrl,
24-
archived: 'false'
25-
}).exec()
26-
// If scan found only this project go to a next interation
27-
if (collisions.length < 2) continue;
28-
logger.info(`Repository ${project.repoUrl} has ${collisions.length} collisions`);
29-
_.forEach(collisions, collision => {
30-
logger.info(`--- ID: ${collision.id}`)
31-
})
32-
collidingUrls.push(project.repoUrl)
20+
for (const repoUrl of project.repoUrls) {
21+
// If url was already found colliding go to a next iteration
22+
if (collidingUrls.includes(repoUrl)) continue;
23+
const collisions = await models.Project.scan({
24+
repoUrl: { contains: project.repoUrl },
25+
archived: 'false'
26+
}).exec()
27+
// If scan found only this project go to a next interation
28+
if (collisions.length < 2) continue;
29+
logger.info(`Repository ${repoUrl} has ${collisions.length} collisions`);
30+
_.forEach(collisions, collision => {
31+
logger.info(`--- ID: ${collision.id}`)
32+
})
33+
collidingUrls.push(repoUrl)
34+
}
3335
}
3436
previousKey = projects.lastKey
3537
previousSize = projects.scannedCount

Diff for: scripts/migrate-repo-url.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const AWS = require('aws-sdk');
2+
const helper = require('../src/common/helper');
3+
const dbHelper = require('../src/common/db-helper');
4+
const Project = require('../src/models').Project;
5+
const Repository = require('../src/models').Repository;
6+
7+
if (process.env.IS_LOCAL=="true") {
8+
AWS.config.update({
9+
endpoint: 'http://localhost:8000'
10+
});
11+
}
12+
var documentClient = new AWS.DynamoDB.DocumentClient();
13+
14+
(async () => {
15+
console.log('Migrating...');
16+
const params = {
17+
TableName: 'Topcoder_X.Project'
18+
};
19+
20+
let items;
21+
do {
22+
items = await documentClient.scan(params).promise();
23+
items.Items.forEach(async (item) => {
24+
console.log(item);
25+
let repoUrls;
26+
if (item.repoUrls) {
27+
repoUrls = item.repoUrls.values;
28+
}
29+
else {
30+
repoUrls = [item.repoUrl];
31+
}
32+
for (const url of repoUrls) { // eslint-disable-line
33+
console.log(`Creating ${url}`);
34+
await dbHelper.create(Repository, {
35+
id: helper.generateIdentifier(),
36+
projectId: item.id,
37+
url,
38+
archived: item.archived,
39+
registeredWebhookId: item.registeredWebhookId
40+
});
41+
}
42+
});
43+
params.ExclusiveStartKey = items.LastEvaluatedKey;
44+
} while(typeof items.LastEvaluatedKey !== 'undefined');
45+
})();

0 commit comments

Comments
 (0)