[sheet-service] available get catalogs
This commit is contained in:
parent
605e99366a
commit
6201dae51d
2 changed files with 47 additions and 47 deletions
|
|
@ -14,8 +14,8 @@ services:
|
||||||
# - ./tsv_data:/app/tsv_data
|
# - ./tsv_data:/app/tsv_data
|
||||||
restart: always
|
restart: always
|
||||||
command: uvicorn main:app --host 0.0.0.0 --port 8124
|
command: uvicorn main:app --host 0.0.0.0 --port 8124
|
||||||
networks:
|
# networks:
|
||||||
- kong-net
|
# - kong-net
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
|
|
@ -25,10 +25,10 @@ services:
|
||||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf
|
- ./nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "8080:80"
|
||||||
networks:
|
# networks:
|
||||||
- kong-net
|
# - kong-net
|
||||||
|
|
||||||
networks:
|
# networks:
|
||||||
kong-net:
|
# kong-net:
|
||||||
external: true
|
# external: true
|
||||||
name: kong-api-gateway_kong-ee-net
|
# name: kong-api-gateway_kong-ee-net
|
||||||
78
main.py
78
main.py
|
|
@ -851,53 +851,53 @@ def startup_event():
|
||||||
thread = threading.Thread(target=redis_message_handler, daemon=True)
|
thread = threading.Thread(target=redis_message_handler, daemon=True)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
# @app.post("/catalogs")
|
@app.post("/catalogs")
|
||||||
# def get_catalogs(req: CatalogRequest):
|
def get_api_catalogs(req: CatalogRequest):
|
||||||
# payload = req.payload
|
payload = req.payload
|
||||||
# if payload.srv_name != SERVICE_NAME:
|
if payload.srv_name != SERVICE_NAME:
|
||||||
# raise HTTPException(status_code=400, detail="Invalid service name")
|
raise HTTPException(status_code=400, detail="Invalid service name")
|
||||||
|
|
||||||
# country = payload.values.country.strip().lower()
|
country = payload.values.country.strip().lower()
|
||||||
# config = COUNTRY_MAPPING.get(country)
|
config = COUNTRY_MAPPING.get(country)
|
||||||
|
|
||||||
# if not config or not config["sheets"]:
|
if not config or not config["sheets"]:
|
||||||
# raise HTTPException(status_code=404, detail="Country or sheets not found")
|
raise HTTPException(status_code=404, detail="Country or sheets not found")
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# # First sheet in Map
|
# First sheet in Map
|
||||||
# target_sheet_name = config["sheets"][0]
|
target_sheet_name = config["sheets"][0]
|
||||||
# client = get_gspread_client()
|
client = get_gspread_client()
|
||||||
# spreadsheet = client.open_by_key(config["spreadsheet_id"])
|
spreadsheet = client.open_by_key(config["spreadsheet_id"])
|
||||||
# worksheet = spreadsheet.worksheet(target_sheet_name)
|
worksheet = spreadsheet.worksheet(target_sheet_name)
|
||||||
|
|
||||||
# # Get A column
|
# Get A column
|
||||||
# col_a = worksheet.col_values(1)
|
col_a = worksheet.col_values(1)
|
||||||
|
|
||||||
# catalogs = []
|
catalogs = []
|
||||||
# # Skip Row 1 (Index 0 in List)
|
# Skip Row 1 (Index 0 in List)
|
||||||
# for row_idx in range(1, len(col_a)):
|
for row_idx in range(1, len(col_a)):
|
||||||
# val = col_a[row_idx].strip()
|
val = col_a[row_idx].strip()
|
||||||
# if not val or val in ["-", "IGNORE"]:
|
if not val or val in ["-", "IGNORE"]:
|
||||||
# continue
|
continue
|
||||||
|
|
||||||
# # Specify file=...
|
# Specify file=...
|
||||||
# # format: Name=Test,file=page_catalog_group_recommend.skt
|
# format: Name=Test,file=page_catalog_group_recommend.skt
|
||||||
# match = re.search(r'file=([^,]+)', val)
|
match = re.search(r'file=([^,]+)', val)
|
||||||
# if match:
|
if match:
|
||||||
# catalog_name = match.group(1).strip()
|
catalog_name = match.group(1).strip()
|
||||||
# lock_info = lock_manager.get_lock_info(country, catalog_name)
|
lock_info = lock_manager.get_lock_info(country, catalog_name)
|
||||||
# catalogs.append({
|
catalogs.append({
|
||||||
# "catalog": catalog_name,
|
"catalog": catalog_name,
|
||||||
# "row_index": row_idx + 1, # Index in Google Sheet
|
"row_index": row_idx + 1, # Index in Google Sheet
|
||||||
# "status": "locked" if lock_info["is_locked"] else "free",
|
"status": "locked" if lock_info["is_locked"] else "free",
|
||||||
# "locked_by": lock_info["locked_by"]
|
"locked_by": lock_info["locked_by"]
|
||||||
# })
|
})
|
||||||
|
|
||||||
# return {"status": "success", "country": country, "catalogs": catalogs}
|
return {"status": "success", "country": country, "catalogs": catalogs}
|
||||||
|
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# traceback.print_exc()
|
traceback.print_exc()
|
||||||
# raise HTTPException(status_code=500, detail=str(e))
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
@app.get("/catalog/data/{country}/{catalog}/{user_id}")
|
@app.get("/catalog/data/{country}/{catalog}/{user_id}")
|
||||||
def get_catalog_data(country: str, catalog: str, user_id: str, background_tasks: BackgroundTasks):
|
def get_catalog_data(country: str, catalog: str, user_id: str, background_tasks: BackgroundTasks):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue