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

Commit 87355ab

Browse files
authored
Merge pull request #403 from topcoder-platform/cleanup_indices
cleanup indices
2 parents 3c5f760 + 792b2df commit 87355ab

8 files changed

+17
-83
lines changed

Diff for: src/common/db-helper.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ async function queryOneActiveCopilotPayment(model, project, username) {
220220
async function queryOneUserGroupMapping(model, groupId, gitlabUserId) {
221221
return await new Promise((resolve, reject) => {
222222
model.query('groupId').eq(groupId)
223-
.filter('gitlabUserId')
224-
.eq(gitlabUserId)
223+
.where('gitlabUserId')
224+
.eq(gitlabUserId.toString())
225225
.all()
226226
.exec((err, result) => {
227227
if (err || !result) {
@@ -244,7 +244,7 @@ async function queryOneUserGroupMapping(model, groupId, gitlabUserId) {
244244
async function queryOneUserTeamMapping(model, teamId, githubUserName, githubOrgId) {
245245
return await new Promise((resolve, reject) => {
246246
model.query('teamId').eq(teamId)
247-
.filter('githubUserName')
247+
.where('githubUserName')
248248
.eq(githubUserName)
249249
.filter('githubOrgId')
250250
.eq(githubOrgId)

Diff for: src/models/Issue.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,14 @@ const schema = new Schema({
1616
// From the receiver service
1717
number: {
1818
type: Number,
19-
required: true,
20-
index: {
21-
global: true,
22-
rangeKey: 'id',
23-
project: true,
24-
name: 'NumberIndex',
25-
},
19+
required: true
2620
},
2721
title: {type: String, required: true},
2822
body: {type: String},
2923
prizes: {type: [Number], required: true}, // extracted from title
3024
provider: {
3125
type: String,
32-
required: true,
33-
index: {
34-
global: true,
35-
rangeKey: 'id',
36-
project: true,
37-
name: 'ProviderIndex',
38-
},
26+
required: true
3927
}, // github or gitlab
4028
repositoryId: {
4129
type: Number,

Diff for: src/models/OwnerUserGroup.js

+3-21
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,12 @@ const schema = new Schema({
1515
},
1616
ownerUsername: {
1717
type: String,
18-
required: true,
19-
index: {
20-
global: true,
21-
rangeKey: 'id',
22-
project: true,
23-
name: 'OwnerUsernameIndex',
24-
},
18+
required: true
2519
},
2620
type: {
2721
type: String,
2822
required: true,
29-
enum: _.values(constants.USER_TYPES),
30-
index: {
31-
global: true,
32-
rangeKey: 'id',
33-
project: true,
34-
name: 'TypeIndex',
35-
},
23+
enum: _.values(constants.USER_TYPES)
3624
},
3725
groupId: {
3826
type: String,
@@ -56,13 +44,7 @@ const schema = new Schema({
5644
},
5745
accessLevel: {
5846
type: String,
59-
required: true,
60-
index: {
61-
global: true,
62-
rangeKey: 'id',
63-
project: true,
64-
name: 'AccessLevelIndex',
65-
},
47+
required: true
6648
},
6749
expiredAt: {
6850
type: String,

Diff for: src/models/OwnerUserTeam.js

+4-28
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,12 @@ const schema = new Schema({
1515
},
1616
ownerUsername: {
1717
type: String,
18-
required: true,
19-
index: {
20-
global: true,
21-
rangeKey: 'id',
22-
project: true,
23-
name: 'OwnerUsernameIndex',
24-
},
18+
required: true
2519
},
2620
type: {
2721
type: String,
2822
required: true,
29-
enum: _.values(constants.USER_TYPES),
30-
index: {
31-
global: true,
32-
rangeKey: 'id',
33-
project: true,
34-
name: 'TypeIndex',
35-
},
23+
enum: _.values(constants.USER_TYPES)
3624
},
3725
teamId: {
3826
type: String,
@@ -46,13 +34,7 @@ const schema = new Schema({
4634
},
4735
githubOrgId: {
4836
type: String,
49-
required: false,
50-
index: {
51-
global: true,
52-
rangeKey: 'id',
53-
project: true,
54-
name: 'RepositoryIdIndex',
55-
},
37+
required: false
5638
},
5739
ownerToken: {type: String, required: true},
5840
identifier: {
@@ -67,13 +49,7 @@ const schema = new Schema({
6749
},
6850
accessLevel: {
6951
type: String,
70-
required: false,
71-
index: {
72-
global: true,
73-
rangeKey: 'id',
74-
project: true,
75-
name: 'AccessLevelIndex',
76-
},
52+
required: false
7753
},
7854
organizationName: { type: String, required: false }
7955
});

Diff for: src/models/User.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ const schema = new Schema({
1616
},
1717
userProviderId: {
1818
type: Number,
19-
required: true,
20-
index: {
21-
global: true,
22-
rangeKey: 'id',
23-
project: true,
24-
name: 'UsesProviderIdIndex',
25-
},
19+
required: true
2620
},
2721
userProviderIdStr: {
2822
type: String,
@@ -41,13 +35,7 @@ const schema = new Schema({
4135
role: {
4236
type: String,
4337
required: true,
44-
enum: _.values(constants.USER_ROLES),
45-
index: {
46-
global: true,
47-
project: true,
48-
name: 'RoleIndex',
49-
rangeKey: 'id',
50-
},
38+
enum: _.values(constants.USER_ROLES)
5139
},
5240
type: {
5341
type: String,

Diff for: src/models/UserGroupMapping.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const schema = new Schema({
1717
index: {
1818
global: true,
1919
project: true,
20-
rangKey: 'gitlabUserId',
20+
rangeKey: 'gitlabUserId',
2121
name: 'GroupIdIndex',
2222
},
2323
},

Diff for: src/models/UserMapping.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const schema = new Schema({
1717
index: {
1818
global: true,
1919
project: true,
20-
rangKey: 'id',
20+
rangeKey: 'id',
2121
name: 'TopcoderUsernameIndex',
2222
},
2323
},

Diff for: src/models/UserTeamMapping.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const schema = new Schema({
1717
index: {
1818
global: true,
1919
project: true,
20-
rangKey: 'githubUserName',
20+
rangeKey: 'githubUserName',
2121
name: 'TopcoderTeamIdIndex',
2222
},
2323
},

0 commit comments

Comments
 (0)