Проработал режим отладки

This commit is contained in:
2025-10-03 18:15:45 +03:00
parent 8c603cc7ab
commit 9688bd644d
5 changed files with 47 additions and 41 deletions

View File

@@ -140,27 +140,27 @@ class ClockifyAPI(ClockifyConfig):
"""
for activity in activities:
try:
resp = requests.put(
self.base_url + self.update_time_entry(
activity_id=activity.id
), json={
"billable": True,
"start": activity.date_start.strftime(config.DATETIME_FORMAT),
"end": activity.date_end.strftime(config.DATETIME_FORMAT) if activity.date_end else None,
"description": activity.description,
"tagIds": [activity.tag_id],
"taskId": activity.vetro_project_id,
"projectId": activity.project_id
}, headers={
"X-API-KEY": self.token
}
)
if resp.ok:
logger.debug(resp.json())
logger.info(f"{Fore.GREEN}{activity}{Fore.RESET}")
if not config.is_debug:
resp = requests.put(
self.base_url + self.update_time_entry(
activity_id=activity.id
), json={
"billable": True,
"start": activity.date_start.strftime(config.DATETIME_FORMAT),
"end": activity.date_end.strftime(config.DATETIME_FORMAT) if activity.date_end else None,
"description": activity.description,
"tagIds": [activity.tag_id],
"taskId": activity.vetro_project_id,
"projectId": activity.project_id
}, headers={
"X-API-KEY": self.token
}
)
if config.is_debug or resp.ok:
logger.info(f"{Fore.GREEN}{activity}{Fore.RESET}")
else:
logger.debug(resp.json())
logger.error(f"{Fore.RED}{activity}{Fore.RESET}")
logger.error(f"{Fore.RED}{activity}{Fore.RESET}")
except Exception as e:
logger.error(e)
return

View File

@@ -37,20 +37,21 @@ class RedmineAPI(RedmineConfig):
if not(not activity.is_tracked and activity.date_end):
continue
try:
resp = requests.post(
self.base_url + self.time_entries_url,
headers={"X-Redmine-Api-Key": self.token},
json={
"time_entry": {
"issue_id": activity.task_id,
"hours": activity.time_spent / (2 if is_beginner else 1),
"activity_id": ActivityTypes.DEVELOPMENT,
"comments": activity.description,
"spent_on": activity.date_start.strftime(self.datetime_format)
if not config.is_debug:
resp = requests.post(
self.base_url + self.time_entries_url,
headers={"X-Redmine-Api-Key": self.token},
json={
"time_entry": {
"issue_id": activity.task_id,
"hours": activity.time_spent / (2 if is_beginner else 1),
"activity_id": ActivityTypes.DEVELOPMENT,
"comments": activity.description,
"spent_on": activity.date_start.strftime(self.datetime_format)
}
}
}
)
if resp.ok:
)
if config.is_debug or resp.ok:
activity.is_tracked = True
tracked.append(activity)
logger.debug(activity)