Hi, is there any easy way to do this?
at the moment the only way I can get it to work is to do the following:
- get project id
- query all tasks in projects
- query all timeslips between task start/end date
- iterate over all returned timeslip user IDs to get user object
- find all timeslips specific to that user and task
- add up hours in each timeslip
for task in project_tasks:
from_date = datetime.strptime(task['created_at'],
‘%Y-%m-%dT%H:%M:%SZ’).strftime(“%Y-%m-%d”)
to_date = datetime.strptime(task[‘updated_at’],
‘%Y-%m-%dT%H:%M:%SZ’).strftime(“%Y-%m-%d”)task_timeslips =
api_get(‘https://api.freeagent.com/v2/timeslips?from_date=%s&to_date=%s’ %
(from_date, to_date), ‘timeslips’)
for task in task_timeslips:
for user in users: if (task['user'] == user['url']): name = str(user['first_name']+" "+user['last_name']) if name in project['times']: project['times'][name][0] =
round(project[‘times’][name][0] + float(task[‘hours’])/8,2)
project[‘times’][name][2] =
round(project[‘times’][name][0] * project[‘times’][name][1],2)
else :
rate = get_rate(name)
days = round(float(task[‘hours’])/8,2)
project[‘times’][name] = [days, rate, rate*days]
this is seriously uncool, if you have 10 employee clocking 10 timeslips per
task and 10 tasks per project it amounts to a hell of a lot of requests,
slowing my site right down.
alot of this could be cut out if you could filter the timeslip request by
project, or task, or person or all of them!! should be very simple to do.
interestingly the freeagent website will show you all clocked hours for
each task which is half of what my code does so there must already be a
simple implementation of it.