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,59 @@
|
||||
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";
|
||||
const queryUrl =
|
||||
"incidents?$select=statuscode,pinswg_appealcasetype,_pinswg_associatedlpa_value&$filter=pinswg_publishtoweb eq true";
|
||||
return relayGet({
|
||||
queryUrl,
|
||||
res,
|
||||
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken),
|
||||
relayPolicy: RELAY_POLICY_BOUNDED_READ,
|
||||
|
||||
transformData: (data) => {
|
||||
const grouped = (data.value || []).reduce((acc, item) => {
|
||||
const key = [
|
||||
item.statuscode,
|
||||
item.pinswg_appealcasetype,
|
||||
item._pinswg_associatedlpa_value || "no-lpa"
|
||||
].join("|");
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = {
|
||||
statuscode: item.statuscode,
|
||||
status: item[
|
||||
"statuscode@OData.Community.Display.V1.FormattedValue"
|
||||
],
|
||||
appealType: item.pinswg_appealcasetype,
|
||||
appealTypeName:
|
||||
item[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
],
|
||||
lpaId: item._pinswg_associatedlpa_value || null,
|
||||
lpaName:
|
||||
item[
|
||||
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
|
||||
] || null,
|
||||
caseCount: 0
|
||||
};
|
||||
}
|
||||
|
||||
acc[key].caseCount += 1;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return Object.values(grouped);
|
||||
},
|
||||
errorResponse: {
|
||||
status: 400,
|
||||
code: "STATUS_COUNTS_FETCH_FAILED",
|
||||
message: "Failed to fetch status counts"
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user