使用Active Collab 5 API进行跨项目时间记录过滤 [英] Cross-project time-record filtering using Active Collab 5 API
问题描述
供Active Collab团队观看此标签.
For Active Collab team watching this tag.
我正在使用新的Active Collab 5 API的项目中工作,尝试运行报告时遇到性能问题.
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.
此调用之后是循环:
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.
现在我在AC中处理大约1500个项目.
Now I work with around 1500 projects in AC.
因此,我需要进行1500个API调用,这会极大地影响性能.有没有一种方法可以构建可以遵循这些原则的东西.
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.
谢谢
推荐答案
在这里您所需要的不是一个要一一遍遍所有项目的请求,而是一个为跨项目报告量身定制的请求. Active Collab 5为此具有正确的API端点-/reports/run
.
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"
注意路线(/reports/run
)和查询参数:
Notice the route (/reports/run
) and query arguments:
-
type
-指定报告的类型,在这种情况下为时间和费用跟踪报告, -
project_filter
-指定项目过滤器.除active
之外,此过滤器的其他有用值是completed
(对于已完成的项目),selected_1,2,3,4
(具有项目ID列表的选定项目),client_1,2,3,4
(对于具有给定ID-的客户的项目s),category_1,2,3,4
(具有给定ID的类别的项目) -
tracked_on_filter
-按跟踪记录的日期进行筛选.要定位到特定日期,请使用selected_date_YYYY-MM-DD
;要定位日期范围,请使用selected_range_YYYY-MM-DD:YYYY-MM-DD
. -
tracked_by_filter
-按跟踪时间的人员进行过滤.它可以具有各种值,例如anybody
,logged_user
,selected_1,2,3
.
type
- specify type of the report, in this case time and expense tracking report,project_filter
- specify project filter. Apart fromactive
, other useful values of this filter arecompleted
(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 useselected_date_YYYY-MM-DD
and to target a date range useselected_range_YYYY-MM-DD:YYYY-MM-DD
.tracked_by_filter
- filter by who tracked the time. It can have various values, likeanybody
,logged_user
,selected_1,2,3
.
要仅列出时间记录,请将type_filter
设置为time
(如果仅列出费用,则设置为expenses
).
To list only time records, set type_filter
to time
(or to expenses
if you want only expenses to be listed).
这篇关于使用Active Collab 5 API进行跨项目时间记录过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!