Skip to content

Commit 31aecbf

Browse files
committed
cache fixes - problems expected
1 parent 87ed985 commit 31aecbf

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

backend/routers/filer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ async def break_filer(cik: str):
376376
report_error(cik, Exception("Filer is broken but has forms."))
377377

378378

379-
@cache(24)
380379
@router.get("/search", tags=["filers"], status_code=200)
380+
@cache(24)
381381
async def search_filers(q: str, limit: int = 4):
382382
hits = await search_companies(q, limit=limit, filter="thirteen_f = true")
383383

@@ -490,8 +490,8 @@ async def estimate(cik: str):
490490
raise HTTPException(500, detail="Error fetching time estimation.")
491491

492492

493-
@cache(1 / 6)
494493
@router.get("/info", tags=["filers"], status_code=200)
494+
@cache(1 / 6)
495495
async def filer_info(cik: str):
496496
filer = database.find_filer(cik, {"_id": 0, "stocks": 0})
497497
if filer is None:
@@ -548,8 +548,8 @@ def convert_keys(obj):
548548
} # Change later
549549

550550

551-
@cache(24)
552551
@router.get("/preview", tags=["filers"], status_code=200)
552+
@cache(24)
553553
async def filer_preview(cik: str, holding_count: int = 5):
554554

555555
if holding_count > 10:
@@ -758,8 +758,8 @@ def get_sample_filers():
758758
return final_list
759759

760760

761-
@cache(24)
762761
@router.get("/record", tags=["filers", "records"], status_code=200)
762+
@cache(24)
763763
async def record(cik: str):
764764
filer = database.find_filer(cik, {"_id": 1})
765765
if filer is None:
@@ -811,8 +811,8 @@ async def record_csv(cik: str, headers: str = None):
811811
)
812812

813813

814-
@cache(24)
815814
@router.get("/record/timeseries", tags=["filers", "records"], status_code=200)
815+
@cache(24)
816816
async def partial_record(cik: str, time: float):
817817
filer = database.find_filer(cik, {"stocks": 1, "tickers": 1, "name": 1})
818818
if not filer:
@@ -894,8 +894,8 @@ async def partial_record(cik: str, time: float):
894894
top_cik_list = json.load(f)
895895

896896

897-
@cache(24)
898897
@router.get("/top", status_code=200)
898+
@cache(24)
899899
async def top_ciks():
900900
try:
901901
filers_sorted = analysis.sort_and_format(top_cik_list)
@@ -911,8 +911,8 @@ async def top_ciks():
911911
popular_cik_list = json.load(f)
912912

913913

914-
@cache(24)
915914
@router.get("/searched", status_code=200)
915+
@cache(24)
916916
async def popular_ciks():
917917
try:
918918
filers_sorted = analysis.sort_and_format(popular_cik_list)

backend/routers/filing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def update_filing(
108108
return {"description": "Filing update started."}
109109

110110

111-
@cache(24)
112111
@router.get("/record", tags=["filers", "filing", "records"], status_code=200)
112+
@cache(24)
113113
async def record_filing(cik: str, access_number):
114114
filer = database.find_filer(cik, {"_id": 1})
115115
if filer is None:
@@ -127,8 +127,8 @@ async def record_filing(cik: str, access_number):
127127
)
128128

129129

130-
@cache(24)
131130
@router.get("/recordcsv", tags=["filers", "filing", "records"], status_code=200)
131+
@cache(24)
132132
async def record_filing_csv(cik: str, access_number: str, headers: str = None):
133133
filer = database.find_filer(cik, {"_id": 1})
134134
if filer is None:
@@ -165,8 +165,8 @@ async def record_filing_csv(cik: str, access_number: str, headers: str = None):
165165
)
166166

167167

168-
@cache(2)
169168
@router.get("/filer", status_code=200)
169+
@cache(2)
170170
async def filings_info(cik: str):
171171
pipeline = [
172172
{"$match": {"cik": cik, "form": {"$in": database.holding_forms}}},
@@ -180,8 +180,8 @@ async def filings_info(cik: str):
180180
return {"filings": filings}
181181

182182

183-
@cache(2)
184183
@router.get("/info", status_code=200)
184+
@cache(2)
185185
async def filing_info(cik: str, access_number: str, include_filer: bool = False):
186186
filing = database.find_filing(cik, access_number, {"_id": 0, "cik": 0, "stocks": 0})
187187
if filing is None:

backend/routers/general.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@
2727
top_cik_list = filer.top_cik_list
2828

2929

30-
@cache(24)
3130
@router.get("/", status_code=200)
31+
@cache(24)
3232
async def info():
3333
return {"description": "Hello World!"}
3434

3535

36-
@cache
3736
@router.get("/undefined", status_code=200)
37+
@cache
3838
async def info_undefined():
3939
return {"description": "Hello World!"}
4040

4141

42-
@cache(4)
4342
@router.get("/health", status_code=200)
43+
@cache(4)
4444
async def health():
4545
health_checks = []
4646

@@ -213,7 +213,7 @@ async def repair_all_filers(
213213
# return {"description": "Hello World!"}
214214

215215

216-
@cache
217216
@router.get("/favicon.ico", status_code=200)
217+
@cache
218218
async def favicon():
219219
return FileResponse(f"{cwd}/static/favicon.ico")

backend/routers/lib/cache.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ async def wrapped(*args, **kwargs):
141141
expire_time = 60 * 60 * hours
142142
store.setex(key, expire_time, value_json)
143143
else:
144-
value_json = result.decode("utf-8")
145-
value = json.loads(value_json)
144+
value = json.loads(result)
146145

147146
return value
148147

backend/routers/stocks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class Cusip(BaseModel):
2424
cusip: list
2525

2626

27-
@cache
2827
@router.get("/query", tags=["stocks"], status_code=200)
28+
@cache
2929
async def query_stocks(cik: str, background: BackgroundTasks):
3030
if cik:
3131
filer = database.search_filer(cik, {"stocks.cusip": 1})
@@ -39,8 +39,8 @@ async def query_stocks(cik: str, background: BackgroundTasks):
3939
return {"description": "Stocks started updating."}
4040

4141

42-
@cache
4342
@router.get("/filer", tags=["stocks", "filers"], status_code=200)
43+
@cache
4444
async def stock_filer(
4545
cik: str,
4646
limit: int,
@@ -77,8 +77,8 @@ async def stock_filer(
7777
)
7878

7979

80-
@cache
8180
@router.get("/filing", tags=["stocks", "filings"], status_code=200)
81+
@cache
8282
async def stock_filing(
8383
cik: str,
8484
access_number: str,
@@ -128,8 +128,8 @@ async def stock_filing(
128128
)
129129

130130

131-
@cache(4)
132131
@router.get("/timeseries", tags=["stocks", "filers"], status_code=200)
132+
@cache(4)
133133
async def stock_timeseries(cik: str, time: float):
134134
filer = database.search_filer(cik, {"stocks.cusip": 1})
135135
if not filer:

0 commit comments

Comments
 (0)