Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mrprompt committed Sep 19, 2020
1 parent 014c0ed commit 0dbc3c4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions uploader/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def get_stations():
return stations.json()


def get_station_id(station_name: str):
stations_list = get_stations()
def get_station_id(station_name: str, stations_list: dict):
stations_data = stations_list['data']

return list(filter(lambda x: x["name"] == station_name, stations_data))
Expand All @@ -41,13 +40,15 @@ def get_station_name(capture):


def upload_captures(captures: list):
stations_db = get_stations()

for capture in captures:
try:
station_name = get_station_name(capture)
station = get_station_id(station_name, stations_db).pop()
except IndexError:
continue

station = get_station_id(station_name).pop()
station_id = station['id']
user_id = station['user_id']

Expand Down

0 comments on commit 0dbc3c4

Please sign in to comment.