fix: remove last element of annotation array if a blank string
style: add debug logs for merge and getting http responses
This commit is contained in:
parent
38a6fcbed6
commit
c7d7448e15
@ -88,6 +88,9 @@ class Grocy(TaskService):
|
||||
|
||||
if 'description' in grocy_task:
|
||||
taskwarrior_task['annotations'] = grocy_task['description'].split('\n')
|
||||
last_element_is_empty_string = taskwarrior_task['annotations'][-1] == ''
|
||||
if last_element_is_empty_string:
|
||||
taskwarrior_task['annotations'] = taskwarrior_task['annotations'][0:-1] # Remove empty string in array
|
||||
|
||||
if 'row_created_timestamp' in grocy_task:
|
||||
taskwarrior_task['entry'] = grocy_task['row_created_timestamp']
|
||||
@ -216,29 +219,23 @@ class Grocy(TaskService):
|
||||
# Delete taskwarrior task
|
||||
if self._should_merge(converted_tw_to_grocy_task, grocy_task):
|
||||
modified_grocy_tasks.append(converted_tw_to_grocy_task)
|
||||
logger.debug('Merged taskwarrior task %s to grocy task %s', converted_tw_to_grocy_task['id'], grocy_task['id'])
|
||||
logger.debug('Merged taskwarrior task %s to grocy task %s', converted_tw_to_grocy_task['uuid'], grocy_task['id'])
|
||||
del remaining_grocy_tasks_to_process[index]
|
||||
# Add taskwarrior task into taskwarrior
|
||||
else:
|
||||
tasks_to_add_to_grocy.append(converted_tw_to_grocy_task)
|
||||
logger.debug('Added grocy task %s to taskwarrior task', grocy_task['id'])
|
||||
|
||||
# Add any remaining taskwarrior tasks not found in grocy into grocy
|
||||
for index in range(len(converted_tw_to_grocy_tasks)):
|
||||
tw_task = self.to_taskwarrior(converted_tw_to_grocy_tasks[index])
|
||||
try:
|
||||
self.tw.task_add(**tw_task)
|
||||
except TaskwarriorError as e:
|
||||
logger.exception('Could not add task %s', e.stderr)
|
||||
|
||||
# Send requests to Grocy service
|
||||
if len(modified_grocy_tasks) > 0:
|
||||
self.modify(modified_grocy_tasks)
|
||||
modify_responses = self.modify(modified_grocy_tasks)
|
||||
logger.debug(added_responses)
|
||||
if len(tasks_to_add_to_grocy) > 0:
|
||||
self.add(tasks_to_add_to_grocy)
|
||||
added_responses = self.add(tasks_to_add_to_grocy)
|
||||
logger.debug(added_responses)
|
||||
|
||||
def merge_into_tw(self, taskwarrior_tasks, grocy_tasks):
|
||||
print('here')
|
||||
# Convert to taskwarrior tasks into grocy tasks
|
||||
converted_tw_to_grocy_tasks = []
|
||||
converted_tw_to_grocy_tasks = [self.to_grocy(task) for task in taskwarrior_tasks]
|
||||
@ -282,10 +279,6 @@ class Grocy(TaskService):
|
||||
except TaskwarriorError as e:
|
||||
logger.exception('Could not add task: %s', e.stderr)
|
||||
|
||||
# Add any remaining taskwarrior tasks not found in grocy into grocy
|
||||
for index in range(len(converted_tw_to_grocy_tasks)):
|
||||
tw_task = self.to_taskwarrior(converted_tw_to_grocy_tasks[index])
|
||||
self.tw.task_add(tw_task)
|
||||
|
||||
def sync(self):
|
||||
# Get all tasks from taskwarrior
|
||||
|
Loading…
Reference in New Issue
Block a user