Skip to content

Commit

Permalink
Pull external journeys tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Lucey committed Sep 4, 2023
1 parent 42b42a8 commit b527182
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/via/bin/upload_journeys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import argparse
import json
import requests

from via.db import db
from via import logger


def main():
parser = argparse.ArgumentParser()
parser.add_argument("url")
args = parser.parse_args()

remove_id = lambda x: x if x.pop("_id") else x

for journey_data in db.raw_journeys.find():
response = requests.post(
args.url + "/push_journey", json=remove_id(journey_data)
)
if response.status_code == 201:
logger.info(f'Created: {journey_data["uuid"]}')
elif response.status_code == 409:
logger.debug(f'Already exists: {journey_data["uuid"]}')


if __name__ == "__main__":
main()

0 comments on commit b527182

Please sign in to comment.