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

Commit 1b08d6d

Browse files
Merge pull request #46 from topcoder-platform/develop
Sync master with develop
2 parents c9272d5 + 1c11585 commit 1b08d6d

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

src/models/Group.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ const GroupSchema = new Schema({
1111
groupId: {
1212
type: String,
1313
hashKey: true
14+
},
15+
createdAt: {
16+
type: String,
17+
required: true
18+
},
19+
updatedAt: {
20+
type: String,
21+
required: true
1422
}
1523
}, {
1624
throughput: {

src/models/Leaderboard.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ const LeaderboardSchema = new Schema({
3232
schema: [String]
3333
},
3434
status: { type: String },
35-
finalDetails: { type: Object }
35+
finalDetails: { type: Object },
36+
createdAt: {
37+
type: String,
38+
required: true
39+
},
40+
updatedAt: {
41+
type: String,
42+
required: true
43+
}
3644
}, {
3745
throughput: {
3846
read: Number(config.AMAZON.DYNAMODB_READ_CAPACITY_UNITS),

src/services/GroupService.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ async function searchGroups () {
2222
* @returns {Object} the created group
2323
*/
2424
async function createGroup (groupId) {
25-
const entity = await Group.get(groupId)
25+
let entity = await Group.get(groupId)
2626
if (entity) {
2727
throw new errors.ConflictError(`groupId # ${groupId} already exists.`)
2828
}
2929

30-
const dbEntity = await Group.create({ groupId })
30+
entity = {
31+
groupId,
32+
createdAt: new Date().toISOString(),
33+
updatedAt: new Date().toISOString()
34+
}
35+
36+
const dbEntity = await Group.create(entity)
3137
try {
32-
await helper.publishMessage('create', 'group', { groupId })
38+
await helper.publishMessage('create', 'group', entity)
3339
} catch (err) {
3440
logger.logFullError(err)
3541
}

src/services/LeaderboardService.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ async function createLeaderboard (challengeId, memberId, review) {
111111
testsPassed,
112112
totalTestCases,
113113
scoreLevel,
114-
groupIds: _.map(groupIds, e => String(e))
114+
groupIds: _.map(groupIds, e => String(e)),
115+
createdAt: new Date().toISOString(),
116+
updatedAt: new Date().toISOString()
115117
}
116118

117119
const dbEntity = await Leaderboard.create(record)
@@ -251,6 +253,12 @@ async function updateLeaderboard (challengeId, memberId, review) {
251253
})
252254
}
253255

256+
if (!existRecords[0].createdAt) {
257+
existRecords[0].createdAt = new Date().toISOString()
258+
}
259+
260+
existRecords[0].updatedAt = new Date().toISOString()
261+
254262
const dbEntity = await existRecords[0].save()
255263
try {
256264
await helper.publishMessage('update', 'leaderboard', existRecords[0])

0 commit comments

Comments
 (0)