update corporate lobbying endpoint

This commit is contained in:
MuslemRahimi 2024-08-08 15:16:42 +02:00
parent c3656edbc9
commit 03d069ea0e
2 changed files with 5 additions and 5 deletions

View File

@ -385,10 +385,10 @@ def create_dataset():
print(f"Total stocks: {len(stock_data)}")
con.close()
batch_size = 10
batch_size = 3
stock_batches = [stock_data[i:i+batch_size] for i in range(0, len(stock_data), batch_size)]
with concurrent.futures.ProcessPoolExecutor(max_workers=os.cpu_count()) as executor:
with concurrent.futures.ProcessPoolExecutor(max_workers=4) as executor:
futures = [executor.submit(process_stocks_batch, batch, csv_files, reports_folder, threshold) for batch in stock_batches]
for future in concurrent.futures.as_completed(futures):

View File

@ -2815,15 +2815,15 @@ async def get_government_contract(data:TickerData, api_key: str = Security(get_a
redis_client.expire(cache_key, 3600*3600) # Set cache expiration time to 1 day
return res
@app.post("/lobbying")
@app.post("/corporate-lobbying")
async def get_lobbying(data:TickerData, api_key: str = Security(get_api_key)):
ticker = data.ticker.upper()
cache_key = f"lobbying-{ticker}"
cache_key = f"corporate-lobbying-{ticker}"
cached_result = redis_client.get(cache_key)
if cached_result:
return orjson.loads(cached_result)
try:
with open(f"json/lobbying/{ticker}.json", 'rb') as file:
with open(f"json/corporate-lobbying/companies/{ticker}.json", 'rb') as file:
res = orjson.loads(file.read())
except:
res = []