Skip imported facts, more 4matting
This commit is contained in:
parent
cb909540fa
commit
19e230932f
@ -88,7 +88,7 @@ class HamsterActivityKimaiMapping(Model):
|
||||
|
||||
|
||||
class HamsterFactKimaiImport(Model):
|
||||
hamster_fact = ForeignKeyField(HamsterFact, backref="mappings")
|
||||
hamster_fact = ForeignKeyField(HamsterFact, backref="imports")
|
||||
kimai_id = SmallIntegerField()
|
||||
imported = DateTimeField(default=datetime.now)
|
||||
|
||||
|
@ -6,7 +6,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
|
||||
from hamstertools.kimai import *
|
||||
from hamstertools.kimai import KimaiAPI, Timesheet, Project, Activity
|
||||
|
||||
logging.basicConfig()
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
@ -7,8 +7,13 @@ from datetime import datetime
|
||||
|
||||
from peewee import JOIN
|
||||
|
||||
from hamstertools.db import *
|
||||
from hamstertools.kimai import *
|
||||
from hamstertools.db import (
|
||||
HamsterCategory,
|
||||
HamsterActivity,
|
||||
HamsterFact,
|
||||
HamsterFactKimaiImport,
|
||||
)
|
||||
from hamstertools.kimai import KimaiAPI, Timesheet, Project, Activity
|
||||
|
||||
api = KimaiAPI()
|
||||
|
||||
@ -53,6 +58,13 @@ for f in facts:
|
||||
)
|
||||
has_errors = True
|
||||
continue
|
||||
if f.imports.count() > 0:
|
||||
print(
|
||||
f"fact {f.id}: activity @{f.activity.id} {f.activity.name} was already imported {f.imports.count()} time(s)"
|
||||
)
|
||||
has_errors = True
|
||||
continue
|
||||
|
||||
|
||||
# if has_errors:
|
||||
# sys.exit(1)
|
||||
@ -66,6 +78,13 @@ for f in facts:
|
||||
f"no mapping, skipping {f.id} ({f.activity.category.name} » {f.activity.name})"
|
||||
)
|
||||
continue
|
||||
|
||||
if f.imports.count() > 0:
|
||||
print(
|
||||
f"already imported, skipping {f.id} ({f.activity.category.name} » {f.activity.name})"
|
||||
)
|
||||
continue
|
||||
|
||||
t = Timesheet(
|
||||
api,
|
||||
activity=mapping.kimai_activity,
|
||||
|
Loading…
Reference in New Issue
Block a user