-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Lucey
committed
Sep 4, 2023
1 parent
42b42a8
commit b527182
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |