Allocations / Grouping

Allocations Grouping endpoint is a powerful sub endpoint for allocations that allows you to make fast grouping queries for summarizing allocation data. Endpoint's URL is:

https://<your_environment_url>/customer-api/1.0/allocations/grouping/

GET

When calling /allocations/grouping/ endpoint without parameters you will get all the allocation hours from the database. The strength in this endpoint is in it's grouping possibility. You may for example group all the allocations by project and/or user. 

With this example call you will get all the allocations and they are grouped first on project level and then on user level:

https://<your_environment_url>/customer-api/1.0/allocations/grouping/?group_by=project,user


Example response:
{
    "count": 1,
    "csvUrl": "/customer-api/1.0/allocations/grouping/?group_by=project,user&workontask.date__gt=2019-01-01&csv=true",
    "itemsPerPage": 500,
    "excelUrl": "/customer-api/1.0/allocations/grouping/?group_by=project,user&workontask.date__gt=2019-01-01&excel=true",
    "next": null,
    "current": 1,
    "lastPage": 1,
    "data": [
        {
            "projectrole__user": 2310,
            "total_hours": 100.0,
            "projectrole__project": 1
        }
    ],
    "previous": null
}

Unit of time grouping

You can also group allocations with time units. Attribute for time unit is timeslot and possible values are: day, week, month, quarter, decade and century.

This example call will first group the allocations with project and user and then with week unit of time.
https://<your_environment_url>/customer-api/1.0/allocations/grouping/?group_by=project,user&timeslot=week

Example response:
{
    "projectrole__project": 1234,
    "total_hours": 34,
    "projectrole__user": 567,
    "datetime": "2020-01-06"
}

In this response projectrole_project is reference to the project and projectrole__user is reference to the user. Total_hours is the allocations for this person in this project on the week starting on datetime day.
How did we do with this article?