обновил вывод успешного переноса активности
This commit is contained in:
@@ -7,6 +7,7 @@ from classes.classes import Task
|
|||||||
from config import RedmineConfig, config
|
from config import RedmineConfig, config
|
||||||
from classes import Activity, ActivityType
|
from classes import Activity, ActivityType
|
||||||
from exceptions import InvalidToken
|
from exceptions import InvalidToken
|
||||||
|
from utils import format_hours
|
||||||
from .constants import (
|
from .constants import (
|
||||||
ACTIVITY_TYPE_BY_VETRO_PROJECT,
|
ACTIVITY_TYPE_BY_VETRO_PROJECT,
|
||||||
CLOCKIFY_ACTIVITY_COMMENT_PREFIX,
|
CLOCKIFY_ACTIVITY_COMMENT_PREFIX,
|
||||||
@@ -48,7 +49,10 @@ class RedmineAPI(RedmineConfig):
|
|||||||
if on_success:
|
if on_success:
|
||||||
on_success(activity)
|
on_success(activity)
|
||||||
tracked.append(activity)
|
tracked.append(activity)
|
||||||
logger.info(f"{Fore.GREEN}{activity}: уже есть в Redmine {Fore.RESET}".ljust(100) + "✅")
|
logger.info(
|
||||||
|
f"{Fore.GREEN}{self.format_activity_result(activity, is_beginner)}"
|
||||||
|
f"{Fore.RESET}".ljust(100) + "✅"
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
if not config.is_debug:
|
if not config.is_debug:
|
||||||
resp = requests.post(
|
resp = requests.post(
|
||||||
@@ -70,7 +74,10 @@ class RedmineAPI(RedmineConfig):
|
|||||||
if on_success:
|
if on_success:
|
||||||
on_success(activity)
|
on_success(activity)
|
||||||
tracked.append(activity)
|
tracked.append(activity)
|
||||||
logger.info(f"{Fore.GREEN}{activity}: успешно {Fore.RESET}".ljust(100) + "✅")
|
logger.info(
|
||||||
|
f"{Fore.GREEN}{self.format_activity_result(activity, is_beginner)}"
|
||||||
|
f"{Fore.RESET}".ljust(100) + "✅"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
errors = resp.json()["errors"]
|
errors = resp.json()["errors"]
|
||||||
@@ -93,6 +100,11 @@ class RedmineAPI(RedmineConfig):
|
|||||||
logger.info(f"{Fore.RED}{activity}{Fore.RESET}".ljust(60) + "❌")
|
logger.info(f"{Fore.RED}{activity}{Fore.RESET}".ljust(60) + "❌")
|
||||||
return tracked
|
return tracked
|
||||||
|
|
||||||
|
def format_activity_result(self, activity: Activity, is_beginner: bool = False) -> str:
|
||||||
|
"""Форматирует строку результата переноса активности."""
|
||||||
|
hours = round(activity.time_spent / (2 if is_beginner else 1), 3)
|
||||||
|
return f"#{activity.task_id} | {format_hours(hours)} | {activity.description}"
|
||||||
|
|
||||||
def get_comment(self, activity: Activity) -> str:
|
def get_comment(self, activity: Activity) -> str:
|
||||||
"""Формирует комментарий Redmine с внешним id активности Clockify."""
|
"""Формирует комментарий Redmine с внешним id активности Clockify."""
|
||||||
return f"{activity.description}\n{CLOCKIFY_ACTIVITY_COMMENT_PREFIX} {activity.id}"
|
return f"{activity.description}\n{CLOCKIFY_ACTIVITY_COMMENT_PREFIX} {activity.id}"
|
||||||
|
|||||||
Reference in New Issue
Block a user