Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
Remi-Gau and sourcery-ai[bot] authored May 28, 2024
1 parent 4bb563f commit ac3c4d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion ui/ecobidas_ui/generate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ def generate():

@blueprint.route("/download", methods=["GET"])
def download():
tmp = md(render_template("generate/report.html"), heading_style="ATX")
try:
tmp = md(render_template("generate/report.html"), heading_style="ATX")
with open(Path(current_app.config["UPLOAD_FOLDER"]) / "report.md", "w") as f:
f.write(tmp)
except IOError as e:
current_app.logger.error(f"File write operation failed: {e}")
return "An error occurred while generating the report.", 500
with open(Path(current_app.config["UPLOAD_FOLDER"]) / "report.md", "w") as f:
f.write(tmp)
return send_from_directory(current_app.config["UPLOAD_FOLDER"], "report.md")
4 changes: 2 additions & 2 deletions ui/ecobidas_ui/protocols/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def get_choices(item_data):
if "https://raw.githubusercontent.com/ohbm/cobidas_schema/master/" in choices:
choices = choices.replace(
"https://raw.githubusercontent.com/ohbm/cobidas_schema/master/",
str(local_cobidas_schema()) + "/",
f"{str(local_cobidas_schema())}/",
)
with open(choices) as f:
choices = json.load(f)
Expand Down Expand Up @@ -255,7 +255,7 @@ def extract_values_participants(df, json_content):
class Found:

def __init__(self, df, age_column) -> None:
self.number_of_subjects = int(len(df))
self.number_of_subjects = len(df)
self.subject_age_mean = float(df[age_column].mean())
self.subject_age_min = df[age_column].min()
self.subject_age_max = df[age_column].max()
Expand Down
3 changes: 2 additions & 1 deletion ui/ecobidas_ui/public/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def home():

@blueprint.route("/faq/")
def faq():
data = json.load(open(STATIC_FOLDER / "json" / "faq.json"))
with open(STATIC_FOLDER / "json" / "faq.json") as f:
data = json.load(f)
return render_template("public/faq.html", data=data)


Expand Down

0 comments on commit ac3c4d3

Please sign in to comment.