Compare commits

..
4 Commits
Author SHA1 Message Date
tanshu ecd3e45632 Version Bump v11.1.9 2023-08-07 12:48:02 +05:30
tanshu 48ec2df10d Fix: Fingerprint was ignoring the time aspect which is obviously very important 2023-08-07 12:47:57 +05:30
tanshu bc61eeacd3 Version Bump v11.1.8 2023-08-07 10:58:49 +05:30
tanshu a051071a1b Fix: Fingerprint upload was broken 2023-08-07 10:58:41 +05:30
7 changed files with 14 additions and 23 deletions
+1 -1
View File
@@ -1 +1 @@
__version__ = "11.1.7" __version__ = "11.1.9"
+5 -14
View File
@@ -8,7 +8,7 @@ from io import StringIO
import brewman.schemas.fingerprint as schemas import brewman.schemas.fingerprint as schemas
from fastapi import APIRouter, Depends, File, HTTPException, UploadFile, status from fastapi import APIRouter, Depends, File, HTTPException, UploadFile, status
from sqlalchemy import bindparam, select from sqlalchemy import select
from sqlalchemy.dialects.postgresql import insert as pg_insert from sqlalchemy.dialects.postgresql import insert as pg_insert
from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
@@ -36,22 +36,13 @@ def upload_prints(
for id_, code in db.execute(select(Employee.id, Employee.code)).all(): for id_, code in db.execute(select(Employee.id, Employee.code)).all():
employees[code] = id_ employees[code] = id_
file_data = read_file(fingerprints) file_data = read_file(fingerprints)
prints = [d for d in fp(file_data, employees) if start <= d.date_.date() <= finish] prints = [d.model_dump() for d in fp(file_data, employees) if start <= d.date_.date() <= finish]
for p in prints:
p["id"] = p.pop("id_")
paged_data = [prints[i : i + 100] for i in range(0, len(prints), 100)] paged_data = [prints[i : i + 100] for i in range(0, len(prints), 100)]
for i, page in enumerate(paged_data): for i, page in enumerate(paged_data):
print(f"Processing page {i} of {len(paged_data)}") print(f"Processing page {i} of {len(paged_data)}")
db.execute( db.execute(pg_insert(Fingerprint).on_conflict_do_nothing(), page)
pg_insert(Fingerprint)
.values(
{
"id": bindparam("id"),
"employee_id": bindparam("employee_id"),
"date": bindparam("date"),
}
)
.on_conflict_do_nothing(),
[p.dict() for p in page],
)
db.commit() db.commit()
except SQLAlchemyError as e: except SQLAlchemyError as e:
raise HTTPException( raise HTTPException(
+4 -4
View File
@@ -20,11 +20,11 @@ class Fingerprint(BaseModel):
@field_validator("date_", mode="before") @field_validator("date_", mode="before")
@classmethod @classmethod
def parse_date(cls, value: date | str) -> date: def parse_date(cls, value: datetime | str) -> datetime:
if isinstance(value, date): if isinstance(value, datetime):
return value return value
return datetime.strptime(value, "%d-%b-%Y").date() return datetime.strptime(value, "%d-%b-%Y %H:%M")
@field_serializer("date_") @field_serializer("date_")
def serialize_date(self, value: date, info: FieldSerializationInfo) -> str: def serialize_date(self, value: date, info: FieldSerializationInfo) -> str:
return value.strftime("%d-%b-%Y") return value.strftime("%d-%b-%Y %H:%M")
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "brewman" name = "brewman"
version = "11.1.7" version = "11.1.9"
description = "Accounting plus inventory management for a restaurant." description = "Accounting plus inventory management for a restaurant."
authors = ["tanshu <git@tanshu.com>"] authors = ["tanshu <git@tanshu.com>"]
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "overlord", "name": "overlord",
"version": "11.1.7", "version": "11.1.9",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",
@@ -2,5 +2,5 @@ export const environment = {
production: true, production: true,
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
version: '11.1.7', version: '11.1.9',
}; };
+1 -1
View File
@@ -6,7 +6,7 @@ export const environment = {
production: false, production: false,
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
version: '11.1.7', version: '11.1.9',
}; };
/* /*