diff --git a/mobile.py b/mobile.py index d4476622..2e6644c2 100644 --- a/mobile.py +++ b/mobile.py @@ -114,7 +114,7 @@ @app.route("/version", methods=["GET"]) def getVersion(): - return {"status": "success", "data": "v3.03-beta"}, status.HTTP_200_OK + return {"status": "success", "data": "v3.04-beta"}, status.HTTP_200_OK @app.route("/exc", methods=["GET"]) diff --git a/routes/reports/general.py b/routes/reports/general.py index 7f0ff4df..e0cd39f7 100644 --- a/routes/reports/general.py +++ b/routes/reports/general.py @@ -17,7 +17,9 @@ def get_report(report): user = User.find(get_jwt_identity()) try: - report_data = general_report_service.get_report(user=user, report=report) + report_data = general_report_service.get_report( + user=user, report=report, filename=request.args.get("filename", "current") + ) except ValidationError as e: return {"status": "error", "message": str(e), "code": e.code}, e.httpStatus diff --git a/services/intervention_service.py b/services/intervention_service.py index f31814be..eea5e13e 100644 --- a/services/intervention_service.py +++ b/services/intervention_service.py @@ -288,7 +288,8 @@ def set_intervention_outcome( ) intervention.update = datetime.today() - intervention.user = user.id + # do not change responsible + # intervention.user = user.id intervention.status = outcome if intervention.economy_type != None: @@ -309,6 +310,11 @@ def set_intervention_outcome( intervention.origin = origin_data intervention.destiny = destiny_data + if not bool(intervention.origin): + # invalid origin + intervention.economy_day_value = 0 + intervention.economy_day_value_manual = True + if ( intervention.economy_type == InterventionEconomyTypeEnum.SUBSTITUTION.value diff --git a/services/reports/cache_service.py b/services/reports/cache_service.py index 6b0b2630..341a1abb 100644 --- a/services/reports/cache_service.py +++ b/services/reports/cache_service.py @@ -55,3 +55,20 @@ def get_cache_data(report, schema, filename="current"): } except ClientError: return {"exists": False, "updatedAt": None} + + +def list_available_reports(schema: str, report: str): + client = _get_client() + files = client.list_objects_v2( + Bucket=Config.CACHE_BUCKET_NAME, + Prefix=f"reports/{schema}/{report}/", + ) + + file_list = [] + for f in files["Contents"]: + filename = f["Key"].split("/")[-1].replace(".gz", "") + if filename != "current": + file_list.append(f["Key"].split("/")[-1].replace(".gz", "")) + + file_list.sort(reverse=True) + return file_list diff --git a/services/reports/general_report_service.py b/services/reports/general_report_service.py index ed0e3e09..6840a8ea 100644 --- a/services/reports/general_report_service.py +++ b/services/reports/general_report_service.py @@ -24,5 +24,8 @@ def get_report(user, report, filename="current"): return { "cached": True, - "url": cache_service.generate_link(report, user.schema), + "availableReports": cache_service.list_available_reports( + schema=user.schema, report=report + ), + "url": cached_link, }