[POC] Implement issue count metric using Elastic
flow metric selectively use Elastic
Make the issue countTo experiment with the query capabilities of Elastic, let's start with a proof of concept. Implement a new class that can calculate the number of issues within a group or project using Elastic.
How
Task 1: implementation
An initial class structure was proposed here where we would have an outer class that accepts the filter parameters. Based on the availability of Elastic and a feature flag we would invoke a backend:
- ActiveRecord-based backend: Use the standard
Issuesfinder
which is currently implemented in theissue_count_resolver.rb
file. - Elastic-based backend: Invokes an Elastic count query.
Paramters:
-
namespace
(can be ProjectNamespace or Group) -
assignee_usernames
, array of usernames -
author_username
, one username -
milestone title
, rule: if this fiter is given, fall back to the ActiveRecord-based backend. Elastic doesn't have this data. -
label_names
, array of label names
Additionally, the returned count should be wrapped with a result object which also contains the backend name or identifier that was used for the calculation. This can be useful later for debugging.
result = Analytics::IssueCount.build(namespace: Group.find(9970)).count
puts result.value # 100
puts reuslt.query_backend # :elastic
Task 2: documentation
As an extra task, we should also mention that the calculation might be based on a different data store depending on the application configuration.
Expected output
The issueCount
node would selectively query the Elastic backend.