Skip to content

Commit

Permalink
Merge pull request #403 from topcoder-platform/cleanup_indices
Browse files Browse the repository at this point in the history
cleanup indices
  • Loading branch information
jmgasper authored Jun 7, 2021
2 parents 3c5f760 + 792b2df commit 87355ab
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 83 deletions.
6 changes: 3 additions & 3 deletions src/common/db-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ async function queryOneActiveCopilotPayment(model, project, username) {
async function queryOneUserGroupMapping(model, groupId, gitlabUserId) {
return await new Promise((resolve, reject) => {
model.query('groupId').eq(groupId)
.filter('gitlabUserId')
.eq(gitlabUserId)
.where('gitlabUserId')
.eq(gitlabUserId.toString())
.all()
.exec((err, result) => {
if (err || !result) {
Expand All @@ -244,7 +244,7 @@ async function queryOneUserGroupMapping(model, groupId, gitlabUserId) {
async function queryOneUserTeamMapping(model, teamId, githubUserName, githubOrgId) {
return await new Promise((resolve, reject) => {
model.query('teamId').eq(teamId)
.filter('githubUserName')
.where('githubUserName')
.eq(githubUserName)
.filter('githubOrgId')
.eq(githubOrgId)
Expand Down
16 changes: 2 additions & 14 deletions src/models/Issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@ const schema = new Schema({
// From the receiver service
number: {
type: Number,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'NumberIndex',
},
required: true
},
title: {type: String, required: true},
body: {type: String},
prizes: {type: [Number], required: true}, // extracted from title
provider: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'ProviderIndex',
},
required: true
}, // github or gitlab
repositoryId: {
type: Number,
Expand Down
24 changes: 3 additions & 21 deletions src/models/OwnerUserGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,12 @@ const schema = new Schema({
},
ownerUsername: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'OwnerUsernameIndex',
},
required: true
},
type: {
type: String,
required: true,
enum: _.values(constants.USER_TYPES),
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'TypeIndex',
},
enum: _.values(constants.USER_TYPES)
},
groupId: {
type: String,
Expand All @@ -56,13 +44,7 @@ const schema = new Schema({
},
accessLevel: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'AccessLevelIndex',
},
required: true
},
expiredAt: {
type: String,
Expand Down
32 changes: 4 additions & 28 deletions src/models/OwnerUserTeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,12 @@ const schema = new Schema({
},
ownerUsername: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'OwnerUsernameIndex',
},
required: true
},
type: {
type: String,
required: true,
enum: _.values(constants.USER_TYPES),
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'TypeIndex',
},
enum: _.values(constants.USER_TYPES)
},
teamId: {
type: String,
Expand All @@ -46,13 +34,7 @@ const schema = new Schema({
},
githubOrgId: {
type: String,
required: false,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'RepositoryIdIndex',
},
required: false
},
ownerToken: {type: String, required: true},
identifier: {
Expand All @@ -67,13 +49,7 @@ const schema = new Schema({
},
accessLevel: {
type: String,
required: false,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'AccessLevelIndex',
},
required: false
},
organizationName: { type: String, required: false }
});
Expand Down
16 changes: 2 additions & 14 deletions src/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const schema = new Schema({
},
userProviderId: {
type: Number,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'UsesProviderIdIndex',
},
required: true
},
userProviderIdStr: {
type: String,
Expand All @@ -41,13 +35,7 @@ const schema = new Schema({
role: {
type: String,
required: true,
enum: _.values(constants.USER_ROLES),
index: {
global: true,
project: true,
name: 'RoleIndex',
rangeKey: 'id',
},
enum: _.values(constants.USER_ROLES)
},
type: {
type: String,
Expand Down
2 changes: 1 addition & 1 deletion src/models/UserGroupMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const schema = new Schema({
index: {
global: true,
project: true,
rangKey: 'gitlabUserId',
rangeKey: 'gitlabUserId',
name: 'GroupIdIndex',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/models/UserMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const schema = new Schema({
index: {
global: true,
project: true,
rangKey: 'id',
rangeKey: 'id',
name: 'TopcoderUsernameIndex',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/models/UserTeamMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const schema = new Schema({
index: {
global: true,
project: true,
rangKey: 'githubUserName',
rangeKey: 'githubUserName',
name: 'TopcoderTeamIdIndex',
},
},
Expand Down

0 comments on commit 87355ab

Please sign in to comment.