checkpoint before fixing a dumb mistake

with dumbeer mistakes
This commit is contained in:
Moses Rolston 2025-03-06 21:01:42 -08:00
parent 21aa013cb8
commit 51233f7d2b
3 changed files with 23 additions and 4 deletions

View File

@ -33,8 +33,12 @@ def get_sponsored():
processed_legislation_count = 0
while 'bioguideids' in cache and len(cache['bioguideids']) > 0:
# Print the current bioguideid being processed
# Step 1: Retrieve a sponsor from the cache
current_bioguideid = cache['bioguideids'].pop(0)
if current_bioguideid is None:
continue
print(f"Processing bioguideid: {current_bioguideid}")
congress_api_url = f"https://api.congress.gov/v3/member/{current_bioguideid}/sponsored-legislation"

View File

@ -34,6 +34,10 @@ def process_sponsors():
while 'legislation_entries' in cache and len(cache['legislation_entries']) > 0:
# Step 1: Retrieve a legislation entry from the cache
legislation_entry = cache['legislation_entries'].pop(0)
if not legislation_entry or 'bioguideid' not in legislation_entry:
continue
bioguideid = legislation_entry['bioguideid']
legislation_properties = {key: value for key, value in legislation_entry.items() if key != 'bioguideid'}

View File

@ -29,14 +29,25 @@ def store_sponsors():
with driver.session() as session:
query = "MATCH (n:Person) RETURN n.bioguideid"
neo4j_logger.info(f"Executing query: {query}")
nodes = session.run(query)
# Convert the nodes to a list of bioguideids
bioguideids = [record['n.bioguideid'] for record in nodes]
# Fetch the records
records = session.run(query)
bioguideids = []
for record in records:
bioguideid = record['n.bioguideid']
if bioguideid is not None:
bioguideids.append(bioguideid)
print(f"Storing bioguideid: {bioguideid}") # Print each bioguideid as it's added
else:
print("Found a record with None bioguideid") # Log any None values
cache['bioguideids'] = bioguideids
neo4j_logger.info(f"Cached bioguideids: {len(bioguideids)}")
# Save the updated cache
save_cache(cache)
return jsonify({"message": "Bioguideids cached successfully", "cached_bioguideids_count": len(cache['bioguideids'])}), 200