fix: implemented solution to not found dadafor report
parent
07e897cd47
commit
3cc53ad3ee
|
@ -2,7 +2,6 @@ import traceback
|
|||
from flask import jsonify
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from pydantic import ValidationError
|
||||
import traceback
|
||||
from bson.errors import InvalidId
|
||||
|
||||
|
||||
|
|
|
@ -63,8 +63,11 @@ class TranscriptionExport(Resource):
|
|||
else:
|
||||
generated_path = service.reportDataXLSX()
|
||||
|
||||
if not generated_path:
|
||||
return {"success": False, "message": "No data found"}, 404
|
||||
|
||||
if not os.path.exists(generated_path):
|
||||
return {"error": "File generation failed"}, 500
|
||||
return {"success": False, "message": "File generation failed"}, 500
|
||||
|
||||
# Move o arquivo gerado para o TMP
|
||||
os.rename(generated_path, filepath)
|
||||
|
|
|
@ -130,9 +130,6 @@ class TranscriptionReportService:
|
|||
self.mongo_results = list(collection.aggregate(pipeline))
|
||||
self.unique_ids = [doc["_id"] for doc in self.mongo_results]
|
||||
|
||||
# print("=====> self.mongo_results: ", self.mongo_results)
|
||||
# exit(1)
|
||||
|
||||
# Pipeline para contagem total
|
||||
count_pipeline = [
|
||||
match_stage,
|
||||
|
@ -355,7 +352,10 @@ class TranscriptionReportService:
|
|||
|
||||
|
||||
def reportDataXLSX(self, hit_report: Optional[bool] = False) -> str:
|
||||
self._fetch_mongo_data(all_data=True)
|
||||
mongo_data = self._fetch_mongo_data(all_data=True)
|
||||
|
||||
if mongo_data["total"] == 0:
|
||||
return
|
||||
|
||||
if hit_report:
|
||||
mysql_data = self._fetch_mysql_data(hit_report=True)
|
||||
|
@ -368,6 +368,15 @@ class TranscriptionReportService:
|
|||
def reportData(self, page: int = 1, page_size: int = 20, hit_report: Optional[bool] = False) -> Dict[str, Any]:
|
||||
mongo_data = self._fetch_mongo_data(page=page, page_size=page_size)
|
||||
|
||||
if mongo_data["total"] == 0:
|
||||
return {
|
||||
"pagination": mongo_data,
|
||||
"data": [],
|
||||
"cost": {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if hit_report:
|
||||
mysql_data = self._fetch_mysql_data(hit_report=True)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue