filter out null items
This commit is contained in:
parent
93dabd7398
commit
61fb5b8207
52
src/index.js
52
src/index.js
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user