File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,14 +38,19 @@ def get_recommendation_list(force_refresh=False):
3838 cached = cache .get (CACHE_KEY )
3939 # 캐시가 없거나 force_refresh(자발적인 refresh)이면
4040 if (not cached ) or force_refresh :
41- raw_data = scrape_oliveyoung_products ()
42- search_results = make_search_results (raw_data )
43- payload = {
44- "results" : search_results ,
45- "fetched_at" : int (time .time ()), # 언제 refresh 됐는지 알 수 있게
46- }
47- cache .set (CACHE_KEY , payload , CACHE_TTL )
48- return payload
41+ try :
42+ raw_data = scrape_oliveyoung_products ()
43+ search_results = make_search_results (raw_data )
44+ payload = {
45+ "results" : search_results ,
46+ "fetched_at" : int (time .time ()), # 언제 refresh 됐는지 알 수 있게
47+ }
48+ cache .set (CACHE_KEY , payload , CACHE_TTL )
49+ return payload
50+ except Exception as e :
51+ if cached :
52+ return cached
53+ return {"results" : [], "fetched_at" : None } # prevent 500
4954
5055 return cached
5156
You can’t perform that action at this time.
0 commit comments