Fix: The date format is more flexible. This is to accommodate the new machine installed in 26.

This commit is contained in:
Amritanshu Agrawal 2023-01-31 17:50:29 +05:30
parent 10aca4071a
commit c99762e6a9
1 changed files with 2 additions and 13 deletions

View File

@ -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(