diff --git a/ExpressAPI/src/managers/UserManager.ts b/ExpressAPI/src/managers/UserManager.ts index 81f129623f4f3f262f35c776762010cce05bc3fe..768878985df0370e70b57646a35a16c534ae1af8 100644 --- a/ExpressAPI/src/managers/UserManager.ts +++ b/ExpressAPI/src/managers/UserManager.ts @@ -34,6 +34,16 @@ class UserManager { async getByIds(ids: Array<number>): Promise<Array<User>> { return Promise.all(ids.map(userId => this.getById(userId))); } + + async getByGitlabId(gitlabId: number): Promise<User | undefined> { + const raw = await db<User>(User.tableName).where('userGitlabId', gitlabId).first(); + + return raw ? this.createObjectFromRawSql(raw) : undefined; + } + + async getByGitlabIds(gitlabIds: Array<number>): Promise<Array<User>> { + return Promise.all(gitlabIds.map(gitlabId => this.getByGitlabId(gitlabId))); + } }