update corporate lobbying endpoint
This commit is contained in:
parent
c3656edbc9
commit
03d069ea0e
@ -385,10 +385,10 @@ def create_dataset():
|
|||||||
print(f"Total stocks: {len(stock_data)}")
|
print(f"Total stocks: {len(stock_data)}")
|
||||||
con.close()
|
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)]
|
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]
|
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):
|
for future in concurrent.futures.as_completed(futures):
|
||||||
|
|||||||
@ -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
|
redis_client.expire(cache_key, 3600*3600) # Set cache expiration time to 1 day
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.post("/lobbying")
|
@app.post("/corporate-lobbying")
|
||||||
async def get_lobbying(data:TickerData, api_key: str = Security(get_api_key)):
|
async def get_lobbying(data:TickerData, api_key: str = Security(get_api_key)):
|
||||||
ticker = data.ticker.upper()
|
ticker = data.ticker.upper()
|
||||||
cache_key = f"lobbying-{ticker}"
|
cache_key = f"corporate-lobbying-{ticker}"
|
||||||
cached_result = redis_client.get(cache_key)
|
cached_result = redis_client.get(cache_key)
|
||||||
if cached_result:
|
if cached_result:
|
||||||
return orjson.loads(cached_result)
|
return orjson.loads(cached_result)
|
||||||
try:
|
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())
|
res = orjson.loads(file.read())
|
||||||
except:
|
except:
|
||||||
res = []
|
res = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user