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

Commit 5586a3a

Browse files
committed
Updates for v5
1 parent 8946acf commit 5586a3a

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/front/src/app/copilot-payments/copilot-payments.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ <h4>You don't have any active payments, Please
7575
<td class="col-lg-2">${{payment.amount}}</td>
7676
<td class="col-lg-2">{{payment.description}}</td>
7777
<td class="col-lg-2">
78-
<a href="{{topcoderUrl}}/direct/contest/detail?projectId={{payment.challengeId}}"
79-
target="_blank">{{payment.challengeId}}</a>
78+
<a href="{{topcoderUrl}}/direct/contest/detail?projectId={{payment.challengeUUID}}"
79+
target="_blank">{{payment.challengeUUID}}</a>
8080
</td>
8181
<td class="col-lg-2">
8282
<button class="btn btn-sm btn-success" ng-click="goPayment(payment)">
@@ -148,8 +148,8 @@ <h4>You don't have any active payments, Please
148148
<td class="col-lg-2">{{payment.project.title}}</td>
149149
<td class="col-lg-2">${{payment.amount}}</td>
150150
<td class="col-lg-2">{{payment.description}}</td>
151-
<td class="col-lg-2"><a href="{{topcoderUrl}}/direct/contest/detail?projectId={{payment.challengeId}}"
152-
target="_blank">{{payment.challengeId}}</a></td>
151+
<td class="col-lg-2"><a href="{{topcoderUrl}}/direct/contest/detail?projectId={{payment.challengeUUID}}"
152+
target="_blank">{{payment.challengeUUID}}</a></td>
153153
</tr>
154154
</tbody>
155155
<tfoot>

src/models/CopilotPayment.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ const schema = new Schema({
4040
name: 'ChallengeIdIndex',
4141
},
4242
},
43+
challengeUUID: {
44+
type: String,
45+
required: false,
46+
index: {
47+
global: true,
48+
project: true,
49+
name: 'ChallengeUUIdIndex'
50+
}
51+
},
4352
closed: {
4453
type: String,
4554
required: true,

src/services/CopilotPaymentService.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ async function getExistingChallengeIdIfExists(dbPayment) {
181181
project: dbPayment.project,
182182
username: dbPayment.username,
183183
closed: 'false',
184-
challengeId: {gt: 0},
185184
});
186185

187186
// if no existing challenge found then it will be created by processor
188187
if (existingPayments) {
189188
dbPayment.challengeId = existingPayments.challengeId;
189+
dbPayment.challengeUUID = existingPayments.challengeUUID;
190190
}
191191
return dbPayment;
192192
}
@@ -212,7 +212,7 @@ async function create(topcoderUser, payment) {
212212
let dbPayment = await dbHelper.create(CopilotPayment, payment);
213213

214214
dbPayment = await getExistingChallengeIdIfExists(dbPayment);
215-
if (!_.isNumber(dbPayment.challengeId) && payment.amount <= 1) {
215+
if (!_.isString(dbPayment.challengeUUID) && payment.amount <= 1) {
216216
throw new Error('The amount must be greater than 1');
217217
}
218218
await dbHelper.update(CopilotPayment, dbPayment.id, dbPayment);
@@ -242,29 +242,33 @@ async function update(topcoderUser, payment) {
242242

243243
// if nothing is changed then discard
244244
if (dbPayment.project === payment.project && dbPayment.amount === payment.amount && dbPayment.description === payment.description) { // eslint-disable-line
245-
return dbPayment.toJSON();
245+
return dbPayment;
246246
}
247247

248248
const existingProjectId = dbPayment.project;
249249
const existingChallengeId = dbPayment.challengeId;
250+
const existingChallengeUUID = dbPayment.challengeUUID;
250251

251252
if (existingProjectId !== payment.project) {
252253
dbPayment.challengeId = null;
253254
payment.challengeId = null;
255+
256+
dbPayment.challengeUUID = null;
257+
payment.challengeUUID = null;
254258
}
255259

256260
dbPayment.amount = payment.amount;
257261
dbPayment.description = payment.description;
258262
dbPayment.project = payment.project;
259263

260264
dbPayment = await getExistingChallengeIdIfExists(dbPayment);
261-
if (!_.isNumber(dbPayment.challengeId) && payment.amount <= 1) {
265+
if (!_.isNull(dbPayment.challengeUUID) && payment.amount <= 1) {
262266
throw new Error('The amount must be greater than 1');
263267
}
264268

265269
await dbHelper.update(CopilotPayment, dbPayment.id, dbPayment);
266270
const paymentUpdateEvent = {
267-
event: dbPayment.challengeId > 0 ? 'copilotPayment.update' : 'copilotPayment.add',
271+
event: dbPayment.challengeUUID ? 'copilotPayment.update' : 'copilotPayment.add',
268272
data: {
269273
payment: _.assign({}, dbPayment),
270274
copilot: topcoderUser,
@@ -281,6 +285,7 @@ async function update(topcoderUser, payment) {
281285
payment: {
282286
project: existingProjectId,
283287
challengeId: existingChallengeId,
288+
challengeUUID: existingChallengeUUID
284289
},
285290
copilot: topcoderUser,
286291
},

0 commit comments

Comments
 (0)