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 trips = body?.data?.activities?.map(async (activity) => {
if (activity.formattedTotal == "$0.00") {
return ""
}
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,
let trips = body?.data?.activities
?.map(async (activity) => {
if (activity.formattedTotal == "$0.00") {
return null
}
}
if (activity.type == "TRIP" || activity.type == "CT") {
// Trip or Share
return await processTrip(activity, usefulRequestHeaders)
}
return { unparsedActivity: activity }
})
if (activity.type == "QUEST") {
// These are all duplicates of MISC items.
return null
}
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 == "TRIP" || activity.type == "CT") {
// Trip or Share
return await processTrip(activity, usefulRequestHeaders)
}
return { unparsedActivity: activity }
})
.filter((item) => item)
if (trips) {
let tripResults = await utils.settlePromises(trips)
uberJSON = [...uberJSON, ...tripResults]