filter out null items

This commit is contained in:
PAlexanderFranklin 2023-11-12 16:09:07 -08:00
parent 93dabd7398
commit 61fb5b8207

View File

@ -69,32 +69,34 @@ async function main() {
}, },
) )
let body = await res.json() let body = await res.json()
let trips = body?.data?.activities?.map(async (activity) => { let trips = body?.data?.activities
if (activity.formattedTotal == "$0.00") { ?.map(async (activity) => {
return "" if (activity.formattedTotal == "$0.00") {
} return null
if (activity.type == "QUEST") {
// These are all duplicates of MISC items.
return ""
}
if (activity.type == "MISC" || activity.activityTitle == "Delivery") {
return {
uuid: activity.uuid,
recognizedAt: new Date(
(activity.recognizedAt ?? 1) * 1000,
).toISOString(),
pickupAddress: activity.tripMetaData?.pickupAddress,
dropOffAddress: activity.tripMetaData?.dropOffAddress,
total: activity.formattedTotal,
type: activity.activityTitle,
} }
} if (activity.type == "QUEST") {
if (activity.type == "TRIP" || activity.type == "CT") { // These are all duplicates of MISC items.
// Trip or Share return null
return await processTrip(activity, usefulRequestHeaders) }
} if (activity.type == "MISC" || activity.activityTitle == "Delivery") {
return { unparsedActivity: activity } return {
}) uuid: activity.uuid,
recognizedAt: new Date(
(activity.recognizedAt ?? 1) * 1000,
).toISOString(),
pickupAddress: activity.tripMetaData?.pickupAddress,
dropOffAddress: activity.tripMetaData?.dropOffAddress,
total: activity.formattedTotal,
type: activity.activityTitle,
}
}
if (activity.type == "TRIP" || activity.type == "CT") {
// Trip or Share
return await processTrip(activity, usefulRequestHeaders)
}
return { unparsedActivity: activity }
})
.filter((item) => item)
if (trips) { if (trips) {
let tripResults = await utils.settlePromises(trips) let tripResults = await utils.settlePromises(trips)
uberJSON = [...uberJSON, ...tripResults] uberJSON = [...uberJSON, ...tripResults]