From c99762e6a9bc9a0a7fb016b50197cb780efc55a7 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Tue, 31 Jan 2023 17:50:29 +0530 Subject: [PATCH] Fix: The date format is more flexible. This is to accommodate the new machine installed in 26. --- brewman/brewman/routers/fingerprint.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/brewman/brewman/routers/fingerprint.py b/brewman/brewman/routers/fingerprint.py index 36157a28..f5f229fc 100644 --- a/brewman/brewman/routers/fingerprint.py +++ b/brewman/brewman/routers/fingerprint.py @@ -86,11 +86,11 @@ def fp(file_data: StringIO, employees: Dict[int, uuid.UUID]) -> List[schemas.Fin header = next(reader) employee_column = 2 date_column = len(header) - 1 - date_format = "%Y/%m/%d %H:%M:%S" if date_column == 6 else "%Y-%m-%d %H:%M:%S" + date_format = "%Y-%m-%d %H:%M:%S" for row in reader: try: employee_code = int(row[employee_column]) # EnNo - date_ = datetime.strptime(row[date_column], date_format) + date_ = datetime.strptime(row[date_column].replace("/", "-"), date_format) if employee_code in employees.keys(): fingerprints.append( schemas.Fingerprint( @@ -104,17 +104,6 @@ def fp(file_data: StringIO, employees: Dict[int, uuid.UUID]) -> List[schemas.Fin return fingerprints -# # Upsert using subquery -# sel = select([literal(uuid.uuid4()), literal(employee_id), literal(date)]).where( -# ~exists([Fingerprint.id]).where( -# and_( -# Fingerprint.employee_id == employee_id, Fingerprint.date == date -# ) -# ) -# ) -# return Fingerprint.__table__.insert().from_select([Fingerprint.id, Fingerprint.employee_id, Fingerprint.date], sel) - - def get_prints(employee_id: uuid.UUID, date_: date, db: Session) -> Tuple[str, str, bool]: prints = ( db.execute(