Improved a bit of the speed of the application

This commit is contained in:
Tiago Ribeiro
2024-12-11 18:32:29 +00:00
parent 76cbf8dc41
commit ce35ba71f4
6 changed files with 148 additions and 163 deletions

View File

@@ -60,6 +60,12 @@ export const getEntitiesAssignments = async (ids: string[]) => {
.toArray();
};
export const countEntitiesAssignments = async (ids: string[], filter?: object) => {
return await db
.collection("assignments")
.countDocuments({ entity: { $in: ids }, ...(filter || {}) })
};
export const getAssignmentsForCorporates = async (userType: Type, idsList: string[], startDate?: Date, endDate?: Date) => {
const assigners = await Promise.all(
idsList.map(async (id) => {