Skip to content

Commit e3ddb86

Browse files
committed
move function for better readability
1 parent 894eba7 commit e3ddb86

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

backend/app/main.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,8 @@ async def clear_index_endpoint(
100100
return {
101101
"message": f"All documents in index {index_name} have been successfully cleared"
102102
}
103-
104-
105-
async def csv_row_generator(upload_file):
106-
df = await run_in_threadpool(pd.read_csv, upload_file.file, delimiter=";", decimal=",", engine="c", encoding="utf-8-sig")
107-
df = df.replace(np.nan, None)
108-
df = df.rename(lambda x: x.lower(), axis='columns')
109-
110-
for data in df.to_dict(orient="records"):
111-
yield {"_index": "politicians", **data}
112103

113104

114-
115105
@app.post(
116106
"/bulk",
117107
response_model=MessageResponse,
@@ -152,7 +142,14 @@ async def bulk(file: UploadFile = File(...), es: Optional[Search] = Depends(get_
152142

153143
return {"message": "success"}
154144

155-
145+
async def csv_row_generator(upload_file):
146+
df = await run_in_threadpool(pd.read_csv, upload_file.file, delimiter=";", decimal=",", engine="c", encoding="utf-8-sig")
147+
df = df.replace(np.nan, None)
148+
df = df.rename(lambda x: x.lower(), axis='columns')
149+
150+
for data in df.to_dict(orient="records"):
151+
yield {"_index": "politicians", **data}
152+
156153
@app.get(
157154
"/politicians",
158155
response_model=PoliticiansPaginated,

0 commit comments

Comments
 (0)