api modified according to doc
This commit is contained in:
parent
813951de43
commit
7683afab7a
@ -269,7 +269,7 @@ export class HomePageDataService {
|
|||||||
async GetCarnetSummaryData(p_emailaddr: string) {
|
async GetCarnetSummaryData(p_emailaddr: string) {
|
||||||
|
|
||||||
let connection;
|
let connection;
|
||||||
let rows = [];
|
let rows:any = [];
|
||||||
try {
|
try {
|
||||||
|
|
||||||
connection = await this.oracleDBService.getConnection()
|
connection = await this.oracleDBService.getConnection()
|
||||||
@ -311,6 +311,41 @@ export class HomePageDataService {
|
|||||||
throw new Error('No cursor returned from the stored procedure');
|
throw new Error('No cursor returned from the stored procedure');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rows = rows.map(obj => {
|
||||||
|
// Create a new object to hold the modified keys
|
||||||
|
let newObj = {};
|
||||||
|
|
||||||
|
// Iterate over the keys of the current object
|
||||||
|
for (let key in obj) {
|
||||||
|
// Replace spaces with underscores in the key
|
||||||
|
let newKey = key.replace(/ /g, "_");
|
||||||
|
newObj[newKey] = obj[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return newObj;
|
||||||
|
});
|
||||||
|
|
||||||
|
rows = rows.reduce((acc, curr) => {
|
||||||
|
// Find if the current item already exists in the accumulator
|
||||||
|
let existing = acc.find(item => item["Service_Provider_Name"] === curr["Service_Provider_Name"] && item.SPID === curr.SPID);
|
||||||
|
|
||||||
|
if (existing) {
|
||||||
|
// If it exists, push the current "cs" and "c c" values into the arrays
|
||||||
|
existing.CARNETSTATUS.push(curr.CARNETSTATUS);
|
||||||
|
existing["Carnet_Count"].push(curr["Carnet_Count"]);
|
||||||
|
} else {
|
||||||
|
// If it doesn't exist, create a new entry
|
||||||
|
acc.push({
|
||||||
|
"Service_Provider_Name": curr["Service_Provider_Name"],
|
||||||
|
SPID: curr.SPID,
|
||||||
|
CARNETSTATUS: [curr.CARNETSTATUS],
|
||||||
|
"Carnet_Count": [curr["Carnet_Count"]]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user