For Active Collab team watching this tag.
I am working on a project that uses new Active Collab 5 API, I am having performance issue trying to run reports.
Example I try to build reports on date-range, and currently to achieve that I need to first run a call to get all projects.
Followed by a loop with this call:
API::get('/projects/'.$id.'/time-records/filtered-by-date?' . http_build_query(['from' => $from, 'to' => $to]))
However we have a large number of projects, in addition to high number of active projects we also need to filter Archived projects as well to get correct reports for billing.
Now I work with around 1500 projects in AC.
So I need to make 1500 API calls which takes a huge performance hit. Is there a way that you can possibly build something that would work along these lines.
API::get(/timerecords/filter-by-date);
with a possible passed parameter that will say (all, active, complited) project state.
Please let me know what you can do or if I have missed something in your documentation that already does this.
Thanks
What you need here is not a request that goes through all projects one by one, but a request that it tailored for cross-project reporting. Active Collab 5 has just the right API endpoint for that - /reports/run
.
As an example, you can use this command to query time records and expenses from all active projects that were tracked today:
curl -H "X-Angie-AuthApiToken: YOUR-API-TOKEN" "http://your.activecollab.com/api/v1/reports/run?type=TrackingFilter&project_filter=active&tracked_on_filter=today"
Notice the route (/reports/run
) and query arguments:
type
- specify type of the report, in this case time and expense tracking report,project_filter
- specify project filter. Apart from active
, other useful values of this filter are completed
(for completed projects), selected_1,2,3,4
(selected projects with a list of project ID-s), client_1,2,3,4
(projects for clients with the given ID-s), category_1,2,3,4
(projects in categories with the given ID-s),tracked_on_filter
- filter by the date when records were tracked. To target a particular date use selected_date_YYYY-MM-DD
and to target a date range use selected_range_YYYY-MM-DD:YYYY-MM-DD
.tracked_by_filter
- filter by who tracked the time. It can have various values, like anybody
, logged_user
, selected_1,2,3
.To list only time records, set type_filter
to time
(or to expenses
if you want only expenses to be listed).