Skip to content

Commit

Permalink
Merge pull request #16 from Kpoke/feat/add_tracks
Browse files Browse the repository at this point in the history
support tracks
  • Loading branch information
Kpoke committed Jun 20, 2023
2 parents 54f428d + 813a628 commit 72383a2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
28 changes: 26 additions & 2 deletions mockdata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"pack_format_version": 2,
"id": "le second format",
"id": "second format",
"wallet_registrations": [
{
"id": "b5fcb38a-fd16-4299-a916-d6fb123d9ec4",
Expand Down Expand Up @@ -153,10 +153,34 @@
"survey_id": "094334b0-22ee-478f-bf61-f752a2679ce5",
"answers": ["response2", "response1"]
}
],
"tracks": [
{
"locations": [
{
"accuracy": 8.201208,
"latitude": 0.963332,
"longitude": 3.3194,
"capturedAt": "2013-08-19T09:35:40Z"
}
],
"sessionId": "65252762-e161-4a1b-92f6-1d0e0f9dd6b5"
},
{
"locations": [
{
"accuracy": 28.201208,
"latitude": 0.9622482833333332,
"longitude": 37.31974508333334,
"capturedAt": "2013-08-19T09:35:40Z"
}
],
"sessionId": "65252762-e161-4a1b-92f6-1d0e0f9dd6b5"
}
]
},
{
"id": "le first format",
"id": "first format",
"registrations": [
{
"planter_identifier": "717457445",
Expand Down
15 changes: 15 additions & 0 deletions process-bulk-uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const v1Requests = async (data, endpoint, httpVerb) => {
const sessions = bulkData.sessions;
const captures = bulkData.captures;
const messages = bulkData.messages;
const tracks = bulkData.tracks;
if (wallet_registrations?.length) {
console.log("processing v2 wallet_registrations");
for (const wallet_registration of wallet_registrations) {
Expand Down Expand Up @@ -137,6 +138,20 @@ const v1Requests = async (data, endpoint, httpVerb) => {
console.log("v2 sessions done");
}

if (tracks?.length) {
console.log("processing v2 tracks");
for (const track of tracks) {
try {
await v2Requests({ ...track, key }, "track", true);
} catch (e) {
shouldBeProcessed = false;
errorHandler(e, track);
continue;
}
}
console.log("v2 tracks done");
}

if (captures?.length) {
console.log("processing v2 captures");
for (const capture of captures) {
Expand Down

0 comments on commit 72383a2

Please sign in to comment.