Updates to patching logic.
This commit is contained in:
parent
c040ff74c9
commit
244f0945bb
3 changed files with 63 additions and 44 deletions
|
|
@ -197,7 +197,7 @@ def init_entry_routes(app):
|
|||
raise TypeError("Invalid model.")
|
||||
|
||||
service = crudkit.crud.get_service(cls)
|
||||
item = service.get(id, params)
|
||||
service.update(id, data=payload, actor="update_entry")
|
||||
|
||||
return {"status": "success", "payload": payload}
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -31,33 +31,35 @@ def init_index_routes(app):
|
|||
"limit": 0
|
||||
})
|
||||
rows = [item.as_dict() for item in inventory_report_rows]
|
||||
df = pd.DataFrame(rows)
|
||||
chart_data = {}
|
||||
if rows:
|
||||
df = pd.DataFrame(rows)
|
||||
|
||||
xtab = pd.crosstab(df["condition"], df["device_type.description"]).astype(int)
|
||||
xtab = pd.crosstab(df["condition"], df["device_type.description"]).astype(int)
|
||||
|
||||
top_labels = (
|
||||
xtab.sum(axis=0)
|
||||
.sort_values(ascending=False)
|
||||
.index.tolist()
|
||||
)
|
||||
xtab = xtab[top_labels]
|
||||
top_labels = (
|
||||
xtab.sum(axis=0)
|
||||
.sort_values(ascending=False)
|
||||
.index.tolist()
|
||||
)
|
||||
xtab = xtab[top_labels]
|
||||
|
||||
preferred_order = [
|
||||
"Deployed", "Working", "Unverified",
|
||||
"Partially Inoperable", "Inoperable",
|
||||
"Removed", "Disposed"
|
||||
]
|
||||
conditions = [c for c in preferred_order if c in xtab.index] + [c for c in xtab.index if c not in preferred_order]
|
||||
xtab = xtab.loc[conditions]
|
||||
preferred_order = [
|
||||
"Deployed", "Working", "Unverified",
|
||||
"Partially Inoperable", "Inoperable",
|
||||
"Removed", "Disposed"
|
||||
]
|
||||
conditions = [c for c in preferred_order if c in xtab.index] + [c for c in xtab.index if c not in preferred_order]
|
||||
xtab = xtab.loc[conditions]
|
||||
|
||||
chart_data = {
|
||||
"labels": top_labels,
|
||||
"datasets": [{
|
||||
"label": cond,
|
||||
"data": xtab.loc[cond].to_list()
|
||||
chart_data = {
|
||||
"labels": top_labels,
|
||||
"datasets": [{
|
||||
"label": cond,
|
||||
"data": xtab.loc[cond].to_list()
|
||||
}
|
||||
for cond in xtab.index]
|
||||
}
|
||||
for cond in xtab.index]
|
||||
}
|
||||
|
||||
columns = [
|
||||
{"field": "start_time", "label": "Start", "format": "date"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue