From b49b0701167b9c1c5320207087b3211d8f42a18e Mon Sep 17 00:00:00 2001 From: Wellheor Date: Mon, 23 Oct 2023 15:14:53 +0800 Subject: [PATCH] . --- contracts/models.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/contracts/models.py b/contracts/models.py index 8d56891e06..57c98b20f1 100644 --- a/contracts/models.py +++ b/contracts/models.py @@ -233,25 +233,25 @@ def get_by_date(date: str, company_id: int, month: bool = False) -> list[dict]: result = [] prev_card_id = -1 examination_data = get_examination_data(company_id, date_start, date_end) - for data in examination_data: - if prev_card_id != data.card_id: + for i in examination_data: + if prev_card_id != i.card_id: result.append( { - "card_id": data.card_id, - "fio": data.family + " " + data.name + " " + data.patronymic, - "harmful_factors": [f"{data.harmful_factor}; "], - "research_id": [data.research_id], - "research_titles": [f"{data.research_title}; "], - "date": data.examination_date.strftime("%d.%m.%Y"), + "card_id": i.card_id, + "fio": i.family + " " + i.name + " " + i.patronymic, + "harmful_factors": [f"{i.harmful_factor}; "], + "research_id": [i.research_id], + "research_titles": [f"{i.research_title}; "], + "date": i.examination_date.strftime("%d.%m.%Y"), } ) else: - if f"{data.harmful_factor}; " not in result[-1]["harmful_factors"]: - result[-1]["harmful_factors"].append(f"{data.harmful_factor}; ") - if data.research_id not in result[-1]["research_id"]: - result[-1]["research_id"].append(data.research_id) - result[-1]["research_titles"].append(f"{data.research_title}; ") - prev_card_id = data.card_id + if f"{i.harmful_factor}; " not in result[-1]["harmful_factors"]: + result[-1]["harmful_factors"].append(f"{i.harmful_factor}; ") + if i.research_id not in result[-1]["research_id"]: + result[-1]["research_id"].append(i.research_id) + result[-1]["research_titles"].append(f"{i.research_title}; ") + prev_card_id = i.card_id if month: result = sorted(result, key=lambda d: d["date"]) else: