File tree Expand file tree Collapse file tree 5 files changed +35
-6
lines changed
Expand file tree Collapse file tree 5 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -23,3 +23,4 @@ start_env.sh
2323.mypy_cache /
2424* secrets *
2525* kustomization *
26+ src /.venv /
Original file line number Diff line number Diff line change 1- from api .API_ingest import shelterluv_api_handler
1+ from api .API_ingest import shelterluv_api_handler , sl_animal_events
22
33def start (conn ):
4- print ("Start Fetching raw data from different API sources" )
4+ print ("Start fetching raw data from different API sources" )
5+
6+ print (" Fetching Shelterluv people" )
7+ #Run each source to store the output in dropbox and in the container as a CSV
8+ slp_count = shelterluv_api_handler .store_shelterluv_people_all (conn )
9+ print (" Finished fetching Shelterluv people - %d records" % slp_count )
10+
11+ print (" Fetching Shelterluv events" )
512 #Run each source to store the output in dropbox and in the container as a CSV
6- shelterluv_api_handler .store_shelterluv_people_all (conn )
7- print ("Finish Fetching raw data from different API sources" )
13+ sle_count = sl_animal_events .slae_test ()
14+ print (" Finished fetching Shelterluv events - %d records" % sle_count )
15+
16+ print ("Finished fetching raw data from different API sources" )
17+
18+
19+ #TODO: Return object with count for each data source?
Original file line number Diff line number Diff line change 88from constants import RAW_DATA_PATH
99from models import ShelterluvPeople
1010
11+
12+ TEST_MODE = os .getenv ("TEST_MODE" )
13+
1114try :
1215 from secrets_dict import SHELTERLUV_SECRET_TOKEN
1316except ImportError :
@@ -78,6 +81,13 @@ def store_shelterluv_people_all(conn):
7881 has_more = response ["has_more" ]
7982 offset += 100
8083
84+ if offset % 1000 == 0 :
85+ print ("Reading offset " , str (offset ))
86+ if TEST_MODE and offset > 1000 :
87+ has_more = False # Break out early
88+
89+
90+
8191 print ("Finish getting shelterluv contacts from people table" )
8292
8393 print ("Start storing latest shelterluvpeople results to container" )
@@ -98,3 +108,5 @@ def store_shelterluv_people_all(conn):
98108
99109 print ("Uploading shelterluvpeople csv to database" )
100110 ShelterluvPeople .insert_from_df (pd .read_csv (file_path , dtype = "string" ), conn )
111+
112+ return offset
Original file line number Diff line number Diff line change 3838 print ("Couldn't get SHELTERLUV_SECRET_TOKEN from file or environment" )
3939
4040
41+ TEST_MODE = os .getenv ("TEST_MODE" ) # if not present, has value None
42+
4143headers = {"Accept" : "application/json" , "X-API-Key" : SHELTERLUV_SECRET_TOKEN }
4244
4345logger = print # print to console for testing
@@ -143,6 +145,8 @@ def get_events_bulk():
143145 offset += limit
144146 if offset % 1000 == 0 :
145147 print ("Reading offset " , str (offset ))
148+ if TEST_MODE and offset > 1000 :
149+ more_records = False # Break out early
146150
147151 else :
148152 return - 5 # AFAICT, this means URL was bad
@@ -155,7 +159,7 @@ def slae_test():
155159 print ("Total events:" , total_count )
156160
157161 b = get_events_bulk ()
158- print ("Records :" , len (b ))
162+ print ("Strored records :" , len (b ))
159163
160164 # f = filter_events(b)
161165 # print(f)
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def user_test2():
2222 return jsonify (("OK from INTERNAL test/test @ " + str (datetime .now ())))
2323
2424
25- @internal_api .route ("/api/ingestRawData" , methods = ["GET" ])
25+ @internal_api .route ("/api/internal/ ingestRawData" , methods = ["GET" ])
2626def ingest_raw_data ():
2727 try :
2828 with engine .begin () as conn :
You can’t perform that action at this time.
0 commit comments