update role claims, refactor getUniqueValues
This commit is contained in:
@@ -155,29 +155,3 @@ export async function listProcessedPermits(
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function getUniqueValuesProcessed(
|
||||
field: string,
|
||||
tenenatId: string
|
||||
) {
|
||||
let values = await processedModel.distinct(field, { tenantId: tenenatId });
|
||||
|
||||
let matchedValues = [];
|
||||
if (field === "county.name") {
|
||||
matchedValues = await orgModel.find().where("name").in(values).exec();
|
||||
} else if (field === "client") {
|
||||
matchedValues = await orgModel.find().where("_id").in(values).exec();
|
||||
} else if (field === "assignedTo") {
|
||||
matchedValues = await userModel.find().where("_id").in(values).exec();
|
||||
}
|
||||
|
||||
if (matchedValues.length > 0) {
|
||||
const newValues = {};
|
||||
for (const item of matchedValues) {
|
||||
newValues[item.id] = item.name;
|
||||
}
|
||||
return newValues;
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user