perfact-api-pd-fastapi 0.3__tar.gz → 0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/PKG-INFO +1 -1
  2. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact/api/pd_fastapi/__init__.py +2 -0
  3. perfact_api_pd_fastapi-0.4/src/perfact/api/pd_fastapi/pdunitlch.py +143 -0
  4. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact_api_pd_fastapi.egg-info/PKG-INFO +1 -1
  5. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact_api_pd_fastapi.egg-info/SOURCES.txt +1 -0
  6. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/README.md +0 -0
  7. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/pyproject.toml +0 -0
  8. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/setup.cfg +0 -0
  9. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact/api/pd_fastapi/kpi.py +0 -0
  10. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact/api/pd_fastapi/pdunit.py +0 -0
  11. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact/api/pd_fastapi/performancedata.py +0 -0
  12. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact/api/pd_fastapi/py.typed +0 -0
  13. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact_api_pd_fastapi.egg-info/dependency_links.txt +0 -0
  14. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact_api_pd_fastapi.egg-info/entry_points.txt +0 -0
  15. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact_api_pd_fastapi.egg-info/requires.txt +0 -0
  16. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/src/perfact_api_pd_fastapi.egg-info/top_level.txt +0 -0
  17. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/tests/locustfile.py +0 -0
  18. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/tests/test_init.py +0 -0
  19. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/tests/test_kpi.py +0 -0
  20. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/tests/test_pdunit.py +0 -0
  21. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/tests/test_performance.py +0 -0
  22. {perfact_api_pd_fastapi-0.3 → perfact_api_pd_fastapi-0.4}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: perfact-api-pd-fastapi
3
- Version: 0.3
3
+ Version: 0.4
4
4
  Summary: PerFact API - SQLAlchemy+FastAPI pd apis package
5
5
  Author-email: Viktor Dick <viktor.dick@perfact.de>
6
6
  License-Expression: GPL-2.0-or-later
@@ -3,6 +3,7 @@ from perfact.api.main.dbsession import APIRouter
3
3
 
4
4
  from .kpi import mount as kpi_mount
5
5
  from .pdunit import mount as pdunitmount
6
+ from .pdunitlch import mount as pdunitlch_mount
6
7
  from .performancedata import mount as performancemount
7
8
 
8
9
  routes = APIRouter()
@@ -12,6 +13,7 @@ routes_pdord = APIRouter()
12
13
  def mount(app: FastAPI):
13
14
  kpi_mount(routes)
14
15
  pdunitmount(routes)
16
+ pdunitlch_mount(routes)
15
17
  performancemount(routes_pdord)
16
18
  app.include_router(routes, prefix="/pd")
17
19
  app.include_router(routes_pdord, prefix="/pd/pdord")
@@ -0,0 +1,143 @@
1
+ import datetime
2
+ from typing import Optional, Sequence
3
+
4
+ from fastapi import HTTPException
5
+ from perfact.api.base.model import PydanticBase
6
+ from perfact.api.main import Auth, DBSession, require_roles
7
+ from perfact.api.main.dbsession import APIRouter
8
+ from perfact.api.pd.model import PdOrdLc, PdOrdLch, PdOrdLct, PdUnitLc, PdUnitLct
9
+ from perfact.api.pd.services.pdunitlch import UnitLchHistoryEntry, get_unit_lch_history
10
+ from pydantic import BaseModel, ConfigDict
11
+ from sqlalchemy import select
12
+
13
+ routes = APIRouter()
14
+
15
+
16
+ class PdUnitLcGet(PydanticBase):
17
+ name: str
18
+ seqnum: Optional[int]
19
+
20
+
21
+ class PdUnitLctGet(PydanticBase):
22
+ name: str
23
+ from_pdunitlc_id: int
24
+ to_pdunitlc_id: int
25
+
26
+
27
+ class PdOrdLcGet(PydanticBase):
28
+ name: str
29
+ isactive: bool
30
+ isexecution: bool
31
+ isfinal: bool
32
+ issetup: bool
33
+ isdowntime: bool
34
+
35
+
36
+ class PdOrdLctGet(PydanticBase):
37
+ name: str
38
+ from_pdordlc_id: int
39
+ to_pdordlc_id: int
40
+
41
+
42
+ class PdOrdLchGet(PydanticBase):
43
+ pdunit_id: Optional[int]
44
+ pdordlct_id: int
45
+ pdord_id: int
46
+
47
+
48
+ class PdUnitLchEntryGet(BaseModel):
49
+ model_config = ConfigDict(from_attributes=True)
50
+ createtime: datetime.datetime
51
+ pdunitlct_name: str
52
+ pdunitlc_name: str
53
+ pdord_num: Optional[str]
54
+
55
+
56
+ @routes.get(
57
+ "/pdunitlc",
58
+ tags=["pd"],
59
+ summary="Get all PdUnitLc",
60
+ response_model=Sequence[PdUnitLcGet],
61
+ )
62
+ @require_roles("PdRead")
63
+ def pdunitlc_get_all(session: DBSession, auth: Auth) -> Sequence[PdUnitLc]:
64
+ return session.execute(select(PdUnitLc)).scalars().all()
65
+
66
+
67
+ @routes.get(
68
+ "/pdunitlct",
69
+ tags=["pd"],
70
+ summary="Get all PdUnitLct",
71
+ response_model=Sequence[PdUnitLctGet],
72
+ )
73
+ @require_roles("PdRead")
74
+ def pdunitlct_get_all(session: DBSession, auth: Auth) -> Sequence[PdUnitLct]:
75
+ return session.execute(select(PdUnitLct)).scalars().all()
76
+
77
+
78
+ @routes.get(
79
+ "/pdordlc",
80
+ tags=["pd"],
81
+ summary="Get all PdOrdLc",
82
+ response_model=Sequence[PdOrdLcGet],
83
+ )
84
+ @require_roles("PdRead")
85
+ def pdordlc_get_all(session: DBSession, auth: Auth) -> Sequence[PdOrdLc]:
86
+ return session.execute(select(PdOrdLc)).scalars().all()
87
+
88
+
89
+ @routes.get(
90
+ "/pdordlct",
91
+ tags=["pd"],
92
+ summary="Get all PdOrdLct",
93
+ response_model=Sequence[PdOrdLctGet],
94
+ )
95
+ @require_roles("PdRead")
96
+ def pdordlct_get_all(session: DBSession, auth: Auth) -> Sequence[PdOrdLct]:
97
+ return session.execute(select(PdOrdLct)).scalars().all()
98
+
99
+
100
+ @routes.get(
101
+ "/pdordlch",
102
+ tags=["pd"],
103
+ summary="Get all PdOrdLch",
104
+ response_model=Sequence[PdOrdLchGet],
105
+ )
106
+ @require_roles("PdRead")
107
+ def pdordlch_get_all(session: DBSession, auth: Auth) -> Sequence[PdOrdLch]:
108
+ return session.execute(select(PdOrdLch)).scalars().all()
109
+
110
+
111
+ @routes.get(
112
+ "/pdunitlch",
113
+ tags=["pd"],
114
+ summary="Get PdUnitLch history for a production unit",
115
+ response_model=list[PdUnitLchEntryGet],
116
+ )
117
+ @require_roles("PdRead")
118
+ def pdunitlch_get(
119
+ session: DBSession,
120
+ auth: Auth,
121
+ pdunit_id: Optional[int] = None,
122
+ pdunit_num: Optional[str] = None,
123
+ duration_s: Optional[int] = None,
124
+ starttime: Optional[datetime.datetime] = None,
125
+ endtime: Optional[datetime.datetime] = None,
126
+ ) -> list[UnitLchHistoryEntry]:
127
+ try:
128
+ return get_unit_lch_history(
129
+ session,
130
+ pdunit_id=pdunit_id,
131
+ pdunit_num=pdunit_num,
132
+ starttime=starttime,
133
+ endtime=endtime,
134
+ duration_s=duration_s,
135
+ )
136
+ except ValueError as exc:
137
+ raise HTTPException(status_code=422, detail=str(exc)) from exc
138
+ except LookupError as exc:
139
+ raise HTTPException(status_code=404, detail=str(exc)) from exc
140
+
141
+
142
+ def mount(app: APIRouter) -> None:
143
+ app.include_router(routes)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: perfact-api-pd-fastapi
3
- Version: 0.3
3
+ Version: 0.4
4
4
  Summary: PerFact API - SQLAlchemy+FastAPI pd apis package
5
5
  Author-email: Viktor Dick <viktor.dick@perfact.de>
6
6
  License-Expression: GPL-2.0-or-later
@@ -4,6 +4,7 @@ tox.ini
4
4
  src/perfact/api/pd_fastapi/__init__.py
5
5
  src/perfact/api/pd_fastapi/kpi.py
6
6
  src/perfact/api/pd_fastapi/pdunit.py
7
+ src/perfact/api/pd_fastapi/pdunitlch.py
7
8
  src/perfact/api/pd_fastapi/performancedata.py
8
9
  src/perfact/api/pd_fastapi/py.typed
9
10
  src/perfact_api_pd_fastapi.egg-info/PKG-INFO