Re4matting

This commit is contained in:
3wc 2023-11-18 11:23:54 +00:00
parent b62eb5cb22
commit 26b8b5f334
3 changed files with 12 additions and 16 deletions

View File

@ -681,14 +681,14 @@ def _import(search, after, before):
): ):
click.secho( click.secho(
f"fact {f.id}: project @{mappings[0].kimai_project.id} {mappings[0].kimai_project.name} does not allow global activity {mappings[0].kimai_activity}", f"fact {f.id}: project @{mappings[0].kimai_project.id} {mappings[0].kimai_project.name} does not allow global activity {mappings[0].kimai_activity}",
fg="red" fg="red",
) )
has_errors = True has_errors = True
continue continue
if f.imports.count() > 0: if f.imports.count() > 0:
click.secho( click.secho(
f"fact {f.id}: activity @{f.activity.id} {f.activity.name} was already imported {f.imports.count()} time(s)", f"fact {f.id}: activity @{f.activity.id} {f.activity.name} was already imported {f.imports.count()} time(s)",
fg="yellow" fg="yellow",
) )
continue continue
@ -717,7 +717,9 @@ def _import(search, after, before):
project=mapping.kimai_project, project=mapping.kimai_project,
begin=f.start_time, begin=f.start_time,
end=f.end_time, end=f.end_time,
description=f.description if f.description != "" else mapping.kimai_description, description=f.description
if f.description != ""
else mapping.kimai_description,
# tags=f.tags if f.tags != '' else mapping.kimai_tags # tags=f.tags if f.tags != '' else mapping.kimai_tags
) )
r = t.upload().json() r = t.upload().json()
@ -725,12 +727,14 @@ def _import(search, after, before):
print(r) print(r)
print(f"{f.id} ({f.activity.category.name} » {f.activity.name})") print(f"{f.id} ({f.activity.category.name} » {f.activity.name})")
from pdb import set_trace from pdb import set_trace
set_trace() set_trace()
else: else:
HamsterFactKimaiImport.create(hamster_fact=f, kimai_id=r["id"]).save() HamsterFactKimaiImport.create(hamster_fact=f, kimai_id=r["id"]).save()
print(f'Created Kimai timesheet {r["id"]}') print(f'Created Kimai timesheet {r["id"]}')
@kimai.group("db") @kimai.group("db")
def db_(): def db_():
pass pass

View File

@ -177,7 +177,7 @@ class Timesheet(BaseAPI):
@staticmethod @staticmethod
def list_by(api, **kwargs): def list_by(api, **kwargs):
kwargs['size'] = 10000 kwargs["size"] = 10000
return [ return [
Timesheet( Timesheet(
api, api,
@ -189,10 +189,7 @@ class Timesheet(BaseAPI):
t["description"], t["description"],
t["tags"], t["tags"],
) )
for t in api.get( for t in api.get("timesheets", params=kwargs)
"timesheets",
params=kwargs
)
] ]
@staticmethod @staticmethod

View File

@ -13,9 +13,7 @@ from ..db import (
KimaiCustomer, KimaiCustomer,
KimaiActivity, KimaiActivity,
) )
from ..kimaiapi import ( from ..kimaiapi import Timesheet as KimaiAPITimesheet
Timesheet as KimaiAPITimesheet
)
from .list import ListPane from .list import ListPane
@ -127,7 +125,7 @@ class KimaiActivityList(ListPane):
activity.id, activity.id,
truncate(activity.name, 40), truncate(activity.name, 40),
activity.visible, activity.visible,
'?' "?",
] ]
for activity in activities for activity in activities
] ]
@ -162,10 +160,7 @@ class KimaiActivityList(ListPane):
activity_id = row_cells[2] activity_id = row_cells[2]
count = len(KimaiAPITimesheet.list_by(self.app.api, activity=activity_id)) count = len(KimaiAPITimesheet.list_by(self.app.api, activity=activity_id))
self.table.update_cell_at( self.table.update_cell_at(Coordinate(row_idx, 5), count)
Coordinate(row_idx, 5),
count
)
class KimaiScreen(Screen): class KimaiScreen(Screen):