Fakultas Ilmu Komputer UI

Commit dab2c5eb authored by Jonathan Christopher Jakub's avatar Jonathan Christopher Jakub
Browse files

[REFACTOR] Fix variable naming

parent d44ef3d7
Pipeline #49754 passed with stages
in 3 minutes and 5 seconds
......@@ -59,33 +59,33 @@ def map_sex_value(sex):
def format_custom_csv_rows(cases_csv_rows):
formated_rows = []
formatted_rows = []
FIELDS_LENGTH = len(INVESTIGATION_CASE_RENDERER_FIELDS)
for row in cases_csv_rows:
formated_row = {}
formatted_row = {}
for field_name_index in range(FIELDS_LENGTH):
original_field_name = INVESTIGATION_CASE_RENDERER_FIELDS[field_name_index]
target_field_name = INVESTIGATION_CASE_HEADER_FIELDS[field_name_index]
formated_row[target_field_name] = row[original_field_name]
formatted_row[target_field_name] = row[original_field_name]
value = formated_row["jenis_kelamin"]
formated_row["jenis_kelamin"] = "Laki-laki" if value else "Perempuan"
value = formatted_row["jenis_kelamin"]
formatted_row["jenis_kelamin"] = "Laki-laki" if value else "Perempuan"
value = json.loads(formated_row["gejala_medis"])
value = json.loads(formatted_row["gejala_medis"])
selected_values = [key for key in value.keys() if value[key]]
formated_row["gejala_medis"] = "; ".join(selected_values)
formatted_row["gejala_medis"] = "; ".join(selected_values)
value = json.loads(formated_row["faktor_risiko"])
value = json.loads(formatted_row["faktor_risiko"])
selected_values = [key for key in value.keys() if value[key]]
formated_row["faktor_risiko"] = "; ".join(selected_values)
formatted_row["faktor_risiko"] = "; ".join(selected_values)
value = formated_row["tanggal_pencatatan"]
formated_row["tanggal_pencatatan"] = timezone.localtime(value)
value = formatted_row["tanggal_pencatatan"]
formatted_row["tanggal_pencatatan"] = timezone.localtime(value)
formated_rows.append(formated_row)
formatted_rows.append(formatted_row)
return formated_rows
return formatted_rows
......@@ -135,9 +135,9 @@ class ExportInvestigationCaseView(APIView):
*INVESTIGATION_CASE_RENDERER_FIELDS
)
)
formated_data = format_custom_csv_rows(data)
formatted_data = format_custom_csv_rows(data)
filename = "cases-{}.csv".format(timezone.localtime(timezone.now()))
headers = {"Content-Disposition": 'attachment; filename="{}"'.format(filename)}
return Response(formated_data, headers=headers)
return Response(formatted_data, headers=headers)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment