Per person time spent on project

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:

  1. get project id
  2. query all tasks in projects
  3. query all timeslips between task start/end date
  4. iterate over all returned timeslip user IDs to get user object
  5. find all timeslips specific to that user and task
  6. 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.

Hi Paolo

Thanks for the feedback, totally understand where you’re coming from. We
haven’t been in a position to put as much development time into the API as
we would have liked, but this is certainly near the top of the list for
when we do get this time.

OllyOn Saturday, April 26, 2014 1:02:53 AM UTC+1, Paolo Memoli wrote:

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:

  1. get project id
  2. query all tasks in projects
  3. query all timeslips between task start/end date
  4. iterate over all returned timeslip user IDs to get user object
  5. find all timeslips specific to that user and task
  6. 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.