Improve processed data
Move setting unparsed data to cards before breakdown so that a successful breakdown overwrites cards. Label what kind of data unparsed data is. Condense string filters into arrays.
This commit is contained in:
parent
6aa5944f90
commit
1659fa65a9
@ -11,28 +11,24 @@ export async function processTrip(activity, usefulRequestHeaders) {
|
||||
},
|
||||
)
|
||||
let body = await res.json()
|
||||
let unparsedData = body
|
||||
let unparsedData = { body }
|
||||
let cards = body?.data?.cards?.filter((card) => {
|
||||
return card.type != "MapCard" && card.type != "TripStatsCard"
|
||||
return !["MapCard", "TripStatsCard"].includes(card.type)
|
||||
})
|
||||
if (cards?.length) {
|
||||
unparsedData = { cards }
|
||||
}
|
||||
let breakdown =
|
||||
cards?.find((card) => card.type == "TripAllPartiesBreakdownCard") ||
|
||||
cards?.find((card) => card.type == "TripBreakdownCard")
|
||||
if (breakdown) {
|
||||
let components = breakdown.components?.filter((comp) => {
|
||||
return (
|
||||
comp.type != "header" &&
|
||||
comp.type != "divider" &&
|
||||
comp.type != "collapsableSection"
|
||||
)
|
||||
return !["header", "divider", "collapsableSection"].includes(comp.type)
|
||||
})
|
||||
if (components?.length) {
|
||||
unparsedData = components
|
||||
unparsedData = { components }
|
||||
}
|
||||
}
|
||||
if (cards?.length) {
|
||||
unparsedData = cards
|
||||
}
|
||||
return {
|
||||
uuid: activity.uuid,
|
||||
recognizedAt: new Date((activity.recognizedAt ?? 1) * 1000).toISOString(),
|
||||
|
Loading…
Reference in New Issue
Block a user