使用 Active Collab 5 API 的跨项目时间记录过滤 [英] Cross-project time-record filtering using Active Collab 5 API

查看:34
本文介绍了使用 Active Collab 5 API 的跨项目时间记录过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Active Collab 团队正在观看此标签.

我正在处理一个使用新 Active Collab 5 API 的项目,我在尝试运行报告时遇到了性能问题.

示例我尝试在日期范围内构建报告,目前要实现这一目标,我需要首先运行调用以获取所有项目.

后跟此调用的循环:

API::get('/projects/'.$id.'/time-records/filtered-by-date?' . http_build_query(['from' => $from, 'to' => $to]))

但是,我们有大量的项目,除了大量的活动项目外,我们还需要过滤已归档的项目,以获得正确的计费报告.

现在我在 AC 中处理了大约 1500 个项目.

所以我需要进行 1500 次 API 调用,这会对性能造成巨大影响.有没有一种方法可以让您构建可以沿着这些方向工作的东西.

API::get(/timerecords/filter-by-date);

带有一个可能的传递参数,表示(所有、活动、已编译)项目状态.

请告诉我您可以做什么,或者我是否遗漏了您的文档中已经这样做的内容.

谢谢

解决方案

这里你需要的不是一个一个一个地遍历所有项目的请求,而是一个为跨项目报告量身定制的请求.Active Collab 5 正好有相应的 API 端点 - /reports/run.

例如,您可以使用此命令从今天跟踪的所有活动项目中查询时间记录和费用:

curl -H "X-Angie-AuthApiToken: YOUR-API-TOKEN" "http://your.activecollab.com/api/v1/reports/run?type=TrackingFilter&project_filter=active&tracked_on_filter=今天"

注意路由 (/reports/run) 和查询参数:

  1. type - 指定报告的类型,在本例中为时间和费用跟踪报告,
  2. project_filter - 指定项目过滤器.除了 active 之外,此过滤器的其他有用值是 completed(对于已完成的项目)、selected_1,2,3,4(具有项目 ID-s 列表)、client_1,2,3,4(具有给定 ID-s 的客户的项目)、category_1,2,3,4(具有给定 ID-s 的类别中的项目),
  3. tracked_on_filter - 按记录被跟踪的日期过滤.要定位特定日期,请使用 selected_date_YYYY-MM-DD,而要定位日期范围,请使用 selected_range_YYYY-MM-DD:YYYY-MM-DD.
  4. tracked_by_filter - 按谁跟踪时间过滤.它可以有各种值,例如 anybodylogged_userselected_1,2,3.

要仅列出时间记录,请将 type_filter 设置为 time(如果只想列出费用,则设置为 expenses).

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:

  1. type - specify type of the report, in this case time and expense tracking report,
  2. 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),
  3. 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.
  4. 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).

这篇关于使用 Active Collab 5 API 的跨项目时间记录过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆