API / Capacity - Grouping

API / Capacity - Grouping


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

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

GET


When calling /capacity/grouping/ endpoint without parameters you will get the same result as without the grouping. But the strength in this endpoint is in it's grouping possibility. So you may for example group the capacity by node. 

Required parameters for this endpoint to really work:
date__gte = 'yyyy-mm-dd'
date__lte = 'yyyy-mm-dd'
timeslot = ['day', 'week', 'month', 'year']
group_by = ['user', 'node', 'role']

Example call:
https://<your_environment_url>/customer-api/1.0/capacity/grouping/?date__gte=2020-01-01&date__lte=2020-12-31&timeslot=month&group_by=user

Example response:
{
    "count": 1,
    "csvUrl": "/customer-api/1.0/capacity/grouping/?group_by=project,user&actual.date__gt=2019-01-01&csv=true",
    "itemsPerPage": 500,
    "excelUrl": "/customer-api/1.0/capacity/grouping/?group_by=project,user&actual.date__gt=2019-01-01&excel=true",
    "next": null,
    "current": 1,
    "lastPage": 1,
    "data": [
    {
      "user_id": 1,
      "entry_date": "2020-01-01",
      "capacity": "184.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-02-01",
      "capacity": "160.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-03-01",
      "capacity": "176.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-04-01",
      "capacity": "176.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-05-01",
      "capacity": "168.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-06-01",
      "capacity": "176.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-07-01",
      "capacity": "184.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-08-01",
      "capacity": "168.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-09-01",
      "capacity": "176.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-10-01",
      "capacity": "176.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-11-01",
      "capacity": "168.00"
    },
    {
      "user_id": 1,
      "entry_date": "2020-12-01",
      "capacity": "184.00"
    },
    ],
    "previous": null
}

How did we do with this article?