Skip to content
Snippets Groups Projects
Commit a39ad1e6 authored by michael.minelli's avatar michael.minelli
Browse files

UserManager => Add get staff function

parent 33242331
No related branches found
No related tags found
No related merge requests found
import User from '../models/User';
import db from '../helpers/DatabaseHelper';
import GitlabUser from '../shared/types/Gitlab/GitlabUser';
import User from '../models/User';
import db from '../helpers/DatabaseHelper';
import GitlabUser from '../shared/types/Gitlab/GitlabUser';
import EnonceStaff from '../models/EnonceStaff';
class UserManager {
......@@ -62,6 +63,14 @@ class UserManager {
async getFromGitlabUsers(gitlabUsers: Array<GitlabUser>, createIfNotExist: boolean = false): Promise<Array<User | number>> {
return Promise.all(gitlabUsers.map(gitlabUser => this.getFromGitlabUser(gitlabUser, createIfNotExist)));
}
async getStaffOfEnonce(enonceName: string): Promise<Array<User>> {
const raw = await db<User>(User.tableName)
.innerJoin(EnonceStaff.tableName, `${ EnonceStaff.tableName }.userId`, `${ User.tableName }.userId`)
.where('enonceName', enonceName);
return raw ? raw.map(user => this.createObjectFromRawSql(user)) : [];
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment