Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.04-beta #319

Merged
merged 5 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
4 changes: 3 additions & 1 deletion routes/reports/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion services/intervention_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions services/reports/cache_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion services/reports/general_report_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Loading