Solved a bug for the master statistical
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import client from "@/lib/mongodb";
|
||||
import {Assignment} from "@/interfaces/results";
|
||||
import {getAllAssignersByCorporate} from "@/utils/groups.be";
|
||||
import {Type} from "@/interfaces/user";
|
||||
|
||||
const db = client.db(process.env.MONGODB_DB);
|
||||
|
||||
@@ -36,10 +37,10 @@ export const getAssignmentsByAssigners = async (ids: string[], startDate?: Date,
|
||||
.toArray();
|
||||
};
|
||||
|
||||
export const getAssignmentsForCorporates = async (idsList: string[], startDate?: Date, endDate?: Date) => {
|
||||
export const getAssignmentsForCorporates = async (userType: Type, idsList: string[], startDate?: Date, endDate?: Date) => {
|
||||
const assigners = await Promise.all(
|
||||
idsList.map(async (id) => {
|
||||
const assigners = await getAllAssignersByCorporate(id);
|
||||
const assigners = await getAllAssignersByCorporate(id, userType);
|
||||
return {
|
||||
corporateId: id,
|
||||
assigners,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {app} from "@/firebase";
|
||||
import {Assignment} from "@/interfaces/results";
|
||||
import {CorporateUser, Group, MasterCorporateUser, StudentUser, TeacherUser, User} from "@/interfaces/user";
|
||||
import {CorporateUser, Group, MasterCorporateUser, StudentUser, TeacherUser, Type, User} from "@/interfaces/user";
|
||||
import client from "@/lib/mongodb";
|
||||
import moment from "moment";
|
||||
import {getLinkedUsers, getUser} from "./users.be";
|
||||
@@ -71,9 +71,9 @@ export const getUsersGroups = async (ids: string[]) => {
|
||||
.toArray();
|
||||
};
|
||||
|
||||
export const getAllAssignersByCorporate = async (corporateID: string): Promise<string[]> => {
|
||||
const linkedTeachers = await getLinkedUsers(corporateID, "mastercorporate", "teacher");
|
||||
const linkedCorporates = await getLinkedUsers(corporateID, "mastercorporate", "corporate");
|
||||
export const getAllAssignersByCorporate = async (corporateID: string, type: Type): Promise<string[]> => {
|
||||
const linkedTeachers = await getLinkedUsers(corporateID, type, "teacher");
|
||||
const linkedCorporates = await getLinkedUsers(corporateID, type, "corporate");
|
||||
|
||||
return [...linkedTeachers.users.map((x) => x.id), ...linkedCorporates.users.map((x) => x.id)];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user