Merged PR 2357: dashboards in admin for appeals and lpa
dashboards in admin for appeals and lpa Related work items: #23527
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { relayGet } from "../middleware/relayForwarding";
|
||||
import { RELAY_POLICY_BOUNDED_READ } from "../middleware/relayPolicyPresets";
|
||||
|
||||
import { statusValues } from "../../../components/utils/caseStagesObj";
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
const queryUrl =
|
||||
"incidents?$apply=groupby((statuscode,pinswg_appealcasetype),aggregate($count as caseCount))&$filter=pinswg_publishtoweb eq true";
|
||||
|
||||
return relayGet({
|
||||
queryUrl,
|
||||
res,
|
||||
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken),
|
||||
relayPolicy: RELAY_POLICY_BOUNDED_READ,
|
||||
transformData: (data) => {
|
||||
const groupedByAppealType = (data.value || []).reduce(
|
||||
(acc, item) => {
|
||||
const appealType = item.pinswg_appealcasetype;
|
||||
|
||||
if (!acc[appealType]) {
|
||||
acc[appealType] = {
|
||||
value:
|
||||
item[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
] || "",
|
||||
appealType,
|
||||
caseCount: 0,
|
||||
statuses: []
|
||||
};
|
||||
}
|
||||
|
||||
acc[appealType].caseCount += item.caseCount || 0;
|
||||
|
||||
acc[appealType].statuses.push({
|
||||
value:
|
||||
item[
|
||||
"statuscode@OData.Community.Display.V1.FormattedValue"
|
||||
] || "",
|
||||
statuscode: item.statuscode,
|
||||
caseCount: item.caseCount || 0
|
||||
});
|
||||
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
return Object.values(groupedByAppealType);
|
||||
},
|
||||
errorResponse: {
|
||||
status: 400,
|
||||
code: "STATUS_COUNTS_FETCH_FAILED",
|
||||
message: "Failed to fetch status counts"
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user