I have an array of objects that looks like this:
[{
date: "07-14-2022",
report: [{
vehicles: [{
id: "uid",
status: "active",
type: "car"
},
{
id: "uid",
status: "oos",
type: "bus"
},
{
id: "uid",
status: "pm",
type: "bus"
}
]
}]
}]
I'm trying to achieve excluding any status other than "oos" or "pm" (was thinking about first using filter here for the first stage). And then I needed to group all the unique values for type so I could provide a breakdown of total numbers for each. So, in the end it would look like:
bus: 2
This is the first stage I was starting to work on, but having trouble...
getReport() {
this.backend.getAnalyticsReport().subscribe(
response => {
console.log(this.processReport(response))
}
)
}
processReport(obj: any) {
return obj.filter((element: any) => this.filterStatus(element.vehicles))
}
filterStatus(element: any) {
if (element.status === 'oos' || 'pm') {
return true
} else {
return false
}
}