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

Version 1.2 #427

Merged
merged 3 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TopcoderXDeploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ You can do this by clicking your logged in username in the upper right of the To

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.

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

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`

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"create-tables": "CREATE_DB=true node scripts/create-update-tables.js",
"migrate-user-mapping": "node scripts/migrate-user-mapping.js",
"add-organisation": "node scripts/add-organisation.js",
"log-repository-collisions": "node scripts/log-repository-collisions.js"
"log-repository-collisions": "node scripts/log-repository-collisions.js",
"migrate-repo-url": "node scripts/migrate-repo-url.js"
},
"dependencies": {
"angular": "~1.8.0",
Expand Down
28 changes: 15 additions & 13 deletions scripts/log-repository-collisions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ async function main() {
archived: 'false'
}).consistent().limit(BATCH_SIZE).startAt(previousKey).exec()
for (const project of projects) {
// If url was already found colliding go to a next iteration
if (collidingUrls.includes(project.repoUrl)) continue;
const collisions = await models.Project.scan({
repoUrl: project.repoUrl,
archived: 'false'
}).exec()
// If scan found only this project go to a next interation
if (collisions.length < 2) continue;
logger.info(`Repository ${project.repoUrl} has ${collisions.length} collisions`);
_.forEach(collisions, collision => {
logger.info(`--- ID: ${collision.id}`)
})
collidingUrls.push(project.repoUrl)
for (const repoUrl of project.repoUrls) {
// If url was already found colliding go to a next iteration
if (collidingUrls.includes(repoUrl)) continue;
const collisions = await models.Project.scan({
repoUrl: { contains: project.repoUrl },
archived: 'false'
}).exec()
// If scan found only this project go to a next interation
if (collisions.length < 2) continue;
logger.info(`Repository ${repoUrl} has ${collisions.length} collisions`);
_.forEach(collisions, collision => {
logger.info(`--- ID: ${collision.id}`)
})
collidingUrls.push(repoUrl)
}
}
previousKey = projects.lastKey
previousSize = projects.scannedCount
Expand Down
45 changes: 45 additions & 0 deletions scripts/migrate-repo-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const AWS = require('aws-sdk');
const helper = require('../src/common/helper');
const dbHelper = require('../src/common/db-helper');
const Project = require('../src/models').Project;
const Repository = require('../src/models').Repository;

if (process.env.IS_LOCAL=="true") {
AWS.config.update({
endpoint: 'http://localhost:8000'
});
}
var documentClient = new AWS.DynamoDB.DocumentClient();

(async () => {
console.log('Migrating...');
const params = {
TableName: 'Topcoder_X.Project'
};

let items;
do {
items = await documentClient.scan(params).promise();
items.Items.forEach(async (item) => {
console.log(item);
let repoUrls;
if (item.repoUrls) {
repoUrls = item.repoUrls.values;
}
else {
repoUrls = [item.repoUrl];
}
for (const url of repoUrls) { // eslint-disable-line
console.log(`Creating ${url}`);
await dbHelper.create(Repository, {
id: helper.generateIdentifier(),
projectId: item.id,
url,
archived: item.archived,
registeredWebhookId: item.registeredWebhookId
});
}
});
params.ExclusiveStartKey = items.LastEvaluatedKey;
} while(typeof items.LastEvaluatedKey !== 'undefined');
})();
Loading