mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
testing pipe
This commit is contained in:
@@ -13,19 +13,20 @@ def get_employee(db: Session, employee_id: int) -> Optional[Employee]:
|
||||
"""Get employee by ID"""
|
||||
return db.query(Employee).filter(Employee.id == employee_id).first()
|
||||
|
||||
def get_employee_by_last_name(db: Session, last_name: str) -> Optional[Employee]:
|
||||
"""Get employee by last name"""
|
||||
return db.query(Employee).filter(Employee.last_name == last_name).first()
|
||||
def get_employee_by_email(db: Session, email: str) -> Optional[Employee]:
|
||||
"""Get employee by email"""
|
||||
return db.query(Employee).filter(Employee.email == email).first()
|
||||
|
||||
def create_employee(db: Session, employee: EmployeeCreate, hashed_password: str) -> Employee:
|
||||
"""Create new employee"""
|
||||
try:
|
||||
db_employee = Employee(
|
||||
first_name=employee.first_name,
|
||||
last_name=employee.last_name,
|
||||
department=employee.department,
|
||||
office=employee.office,
|
||||
hashed_password=hashed_password
|
||||
email=employee.email,
|
||||
full_name=employee.full_name,
|
||||
hashed_password=hashed_password,
|
||||
is_active=employee.is_active,
|
||||
is_admin=employee.is_admin,
|
||||
department=employee.department
|
||||
)
|
||||
db.add(db_employee)
|
||||
db.commit()
|
||||
|
@@ -48,8 +48,7 @@ def get_request_details(db: Session, request_id: int) -> Optional[Dict]:
|
||||
"status": request.status,
|
||||
"department": request.department,
|
||||
"created_at": request.created_at.isoformat(),
|
||||
"employee_first_name": employee.first_name,
|
||||
"employee_last_name": employee.last_name
|
||||
"employee_full_name": employee.full_name
|
||||
}
|
||||
|
||||
def get_employee_requests(db: Session, employee_id: int) -> list[Request]:
|
||||
@@ -81,6 +80,12 @@ def get_statistics(db: Session) -> Dict:
|
||||
func.count(Request.id)
|
||||
).group_by(Request.status).all()
|
||||
)
|
||||
|
||||
# Добавляем статусы с нулевым количеством
|
||||
for status in RequestStatus:
|
||||
if status not in by_status:
|
||||
by_status[status] = 0
|
||||
|
||||
return {
|
||||
"total": total,
|
||||
"by_status": by_status
|
||||
|
Reference in New Issue
Block a user