From 792b2dfba82abaa99eac4af8be51ac0c7547f92d Mon Sep 17 00:00:00 2001 From: Afrisal Yodi Purnama Date: Mon, 7 Jun 2021 09:23:40 +0700 Subject: [PATCH] cleanup indices --- src/common/db-helper.js | 6 +++--- src/models/Issue.js | 16 ++-------------- src/models/OwnerUserGroup.js | 24 +++--------------------- src/models/OwnerUserTeam.js | 32 ++++---------------------------- src/models/User.js | 16 ++-------------- src/models/UserGroupMapping.js | 2 +- src/models/UserMapping.js | 2 +- src/models/UserTeamMapping.js | 2 +- 8 files changed, 17 insertions(+), 83 deletions(-) diff --git a/src/common/db-helper.js b/src/common/db-helper.js index b758648..3ae537b 100644 --- a/src/common/db-helper.js +++ b/src/common/db-helper.js @@ -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) { @@ -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) diff --git a/src/models/Issue.js b/src/models/Issue.js index b17251e..038c4d1 100644 --- a/src/models/Issue.js +++ b/src/models/Issue.js @@ -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, diff --git a/src/models/OwnerUserGroup.js b/src/models/OwnerUserGroup.js index c3b729e..24e0544 100644 --- a/src/models/OwnerUserGroup.js +++ b/src/models/OwnerUserGroup.js @@ -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, @@ -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, diff --git a/src/models/OwnerUserTeam.js b/src/models/OwnerUserTeam.js index 3aadc29..177a26d 100644 --- a/src/models/OwnerUserTeam.js +++ b/src/models/OwnerUserTeam.js @@ -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, @@ -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: { @@ -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 } }); diff --git a/src/models/User.js b/src/models/User.js index d187128..12a5ef9 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -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, @@ -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, diff --git a/src/models/UserGroupMapping.js b/src/models/UserGroupMapping.js index c98ea32..12442fb 100644 --- a/src/models/UserGroupMapping.js +++ b/src/models/UserGroupMapping.js @@ -17,7 +17,7 @@ const schema = new Schema({ index: { global: true, project: true, - rangKey: 'gitlabUserId', + rangeKey: 'gitlabUserId', name: 'GroupIdIndex', }, }, diff --git a/src/models/UserMapping.js b/src/models/UserMapping.js index f1be34c..7ab8a86 100644 --- a/src/models/UserMapping.js +++ b/src/models/UserMapping.js @@ -17,7 +17,7 @@ const schema = new Schema({ index: { global: true, project: true, - rangKey: 'id', + rangeKey: 'id', name: 'TopcoderUsernameIndex', }, }, diff --git a/src/models/UserTeamMapping.js b/src/models/UserTeamMapping.js index a42f59f..81a6362 100644 --- a/src/models/UserTeamMapping.js +++ b/src/models/UserTeamMapping.js @@ -17,7 +17,7 @@ const schema = new Schema({ index: { global: true, project: true, - rangKey: 'githubUserName', + rangeKey: 'githubUserName', name: 'TopcoderTeamIdIndex', }, }, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy