Добавил новый датакласс для Деятельности трудочасов и настроил их динамическую подгрузку из Redmine
This commit is contained in:
@@ -6,7 +6,7 @@ import requests
|
||||
from tqdm import tqdm
|
||||
|
||||
from config import ClockifyConfig, config
|
||||
from classes import Activity, Tag
|
||||
from classes import Activity, ActivityType, Tag
|
||||
from exceptions import InvalidToken
|
||||
from utils import time_to_hour
|
||||
|
||||
@@ -106,9 +106,7 @@ class ClockifyAPI(ClockifyConfig):
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
return
|
||||
|
||||
|
||||
|
||||
def _check_token(self, token: str) -> str:
|
||||
resp = requests.get(self.base_url + self.user_url, headers={"X-API-KEY": token})
|
||||
if not resp.ok:
|
||||
|
||||
@@ -4,8 +4,8 @@ import requests
|
||||
from tqdm import tqdm
|
||||
|
||||
from config import RedmineConfig, config
|
||||
from classes import Activity
|
||||
from enums import ActivityType
|
||||
from classes import Activity, ActivityType
|
||||
from enums import ActivityType as ActivityTypeEnum
|
||||
from exceptions import InvalidToken
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -34,7 +34,7 @@ class RedmineAPI(RedmineConfig):
|
||||
"time_entry": {
|
||||
"issue_id": activity.task_id,
|
||||
"hours": activity.time_spent,
|
||||
"activity_id": ActivityType.DEVELOPMENT,
|
||||
"activity_id": ActivityTypeEnum.DEVELOPMENT,
|
||||
"comments": activity.description,
|
||||
"spent_on": activity.date_start.strftime(self.datetime_format)
|
||||
}
|
||||
@@ -55,7 +55,16 @@ class RedmineAPI(RedmineConfig):
|
||||
else:
|
||||
logger.info(f"Не все задачи были занесены в Redmine. Занесено {len(tracked)}")
|
||||
return tracked
|
||||
|
||||
|
||||
def get_time_entry_activities(self):
|
||||
resp = requests.get(self.base_url + self.time_entry_activities, headers={"X-Redmine-API-KEY": self.token})
|
||||
logging.debug(resp.json())
|
||||
if resp.ok:
|
||||
return [
|
||||
ActivityType(id=act.get("id"), title=act.get("name"))
|
||||
for act in resp.json().get("time_entry_activities")
|
||||
if act.get("active")
|
||||
]
|
||||
|
||||
def _check_token(self, token):
|
||||
resp = requests.get(self.base_url + self.my_account_url, headers={"X-Redmine-Api-Key": token})
|
||||
|
||||
Reference in New Issue
Block a user