Fix feature warnings

We enable the feature flag so sbt displays the warnings.

The following warnings are fixed:

[warn] /home/darius/dev/gerritforge/analytics/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/AggregatedHistogramFilterByDates.scala:32:36: postfix operator >= should be enabled
[warn] by making the implicit value scala.language.postfixOps visible.
[warn] This can be achieved by adding the import clause 'import scala.language.postfixOps'
[warn] or by setting the compiler option -language:postfixOps.
[warn] See the Scaladoc for value scala.language.postfixOps for a discussion
[warn] why the feature should be explicitly enabled.
[warn]     if (from.fold(true)(commitDate >=) && to.fold(true)(commitDate <)) {
[warn]                                    ^
[warn] /home/darius/dev/gerritforge/analytics/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/AggregatedHistogramFilterByDates.scala:32:68: postfix operator < should be enabled
[warn] by making the implicit value scala.language.postfixOps visible.
[warn]     if (from.fold(true)(commitDate >=) && to.fold(true)(commitDate <)) {
[warn]                                                                    ^
[warn] /home/darius/dev/gerritforge/analytics/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/DateConversions.scala:21:16: implicit conversion method isoStringToLongDate should be enabled
[warn] by making the implicit value scala.language.implicitConversions visible.
[warn] This can be achieved by adding the import clause 'import scala.language.implicitConversions'
[warn] or by setting the compiler option -language:implicitConversions.
[warn] See the Scaladoc for value scala.language.implicitConversions for a discussion
[warn] why the feature should be explicitly enabled.
[warn]   implicit def isoStringToLongDate(s: String): Long = JavaSqlTimestampHelper.parseTimestamp(s).getTime
[warn]                ^

This warning will be fixed in a subsequent commit once we've bumped
Scala to a version containing `Using`.
[warn] /home/darius/dev/gerritforge/analytics/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/ManagedResources.scala:22:16: reflective access of structural type member method close should be enabled
[warn] by making the implicit value scala.language.reflectiveCalls visible.
[warn] This can be achieved by adding the import clause 'import scala.language.reflectiveCalls'
[warn] or by setting the compiler option -language:reflectiveCalls.
[warn] See the Scaladoc for value scala.language.reflectiveCalls for a discussion
[warn] why the feature should be explicitly enabled.
[warn]       resource.close()
[warn]                ^
[warn] four warnings found

Change-Id: I0f7ee02cba2cae2878fe4d5299044e15e5aead56
5 files changed
tree: 32257ad09da0afd06ed3bef82f19edfcf8e0ba4f
  1. project/
  2. src/
  3. .gitignore
  4. build.sbt
  5. config.md
  6. LICENSE
  7. README.md
README.md

Analytics extraction plugin

Extract commit and review data from Gerrit projects and expose aggregated metrics over REST and SSH API.

How to build

To build the analytics plugin you need to have SBT 0.13.x or later installed. If you have a Linux operating system, see the Installing SBT on Linux instructions

Clone the analytics plugin and execute sbt assembly.

Example:

   $ git clone https://gerrit.googlesource.com/plugins/analytics
   $ cd analytics && sbt assembly

The plugin jar file is created under target/scala-2.11/analytics.jar

How to install

Copy the analytics.jar generated onto the Gerrit's /plugins directory.

How to configure

See the relevant section in the configuration guide

How to use

Adds new REST API and SSH commands to allow the extraction of repository statistics from Gerrit repositories and changes.

API

All the API share the same syntax and behaviour. Differently from the standard Gerrit REST API, the JSON collections are returned as individual lines and streamed over the socket I/O. The choice is driven by the fact that the typical consumer of these API is a BigData batch process, typically external to Gerrit and hosted on a separate computing cluster.

A large volume of data can be potentially generated: splitting the output file into separate lines helps the BigData processing in the splitting, shuffling and sorting phase.

Contributors

Extract a unordered list of project contributors statistics, including the commits data relevant for statistics purposes, such as number of involved files, and optionally also the list of belonging branches, number of added/deleted lines, timestamp and merge flag.

Optionally, extract information on issues using the commentLink Gerrit configuration and enrich the statistics with the issue-ids and links obtained from the commit message.

REST

/projects/{project-name}/analytics~contributors[?since=2006-01-02[15:04:05[.890][-0700]]][&until=2018-01-02[18:01:03[.333][-0700]]][&aggregate=email_year]

SSH

analytics contributors {project-name} [--since 2006-01-02[15:04:05[.890][-0700]]] [--until 2018-01-02[18:01:03[.333][-0700]]]

Parameters

  • --since -b Starting timestamp to consider
  • --until -e Ending timestamp (excluded) to consider
  • --aggregate -granularity -g one of email, email_year, email_month, email_day, email_hour defaulting to aggregation by email
  • --extract-branches -r enables splitting of aggregation by branch name and expose branch name in the payload

NOTE: Timestamp format is consistent with Gerrit's query syntax, see /Documentation/user-search.html for details.

Examples

  • REST:
   $ curl http://gerrit.mycompany.com/projects/myproject/analytics~contributors
   {"name":"John Doe","email":"john.doe@mycompany.com","num_commits":1, "num_files":4,"added_lines":9,"deleted_lines":1, "commits":[{"sha1":"6a1f73738071e299f600017d99f7252d41b96b4b","date":"Apr 28, 2011 5:13:14 AM","merge":false,"bot_like": false}],"is_bot_like": false}
   {"name":"Matt Smith","email":"matt.smith@mycompany.com","num_commits":1, "num_files":1,"added_lines":90,"deleted_lines":10,"commits":[{"sha1":"54527e7e3086758a23e3b069f183db6415aca304","date":"Sep 8, 2015 3:11:23 AM","merge":true,"bot_like": false}],"branches":["master"],"is_bot_like": false}
  • SSH:
   $ ssh -p 29418 admin@gerrit.mycompany.com analytics contributors myproject --since 2017-08-01 --until 2017-12-31 --extract-issues
   {"name":"John Doe","email":"john.doe@mycompany.com","num_commits":1, "num_files":4,"added_lines":9,"deleted_lines":1, "commits":[{"sha1":"6a1f73738071e299f600017d99f7252d41b96b4b","date":"Apr 28, 2011 5:13:14 AM","merge":false,"bot_like": false}],"is_bot_like": false,"issues_codes":["PRJ-001"],"issues_links":["https://jira.company.org/PRJ-001"]}
   {"name":"Matt Smith","email":"matt.smith@mycompany.com","num_commits":1, "num_files":1,"added_lines":90,"deleted_lines":10,"commits":[{"sha1":"54527e7e3086758a23e3b069f183db6415aca304","date":"Sep 8, 2015 3:11:23 AM","merge":true,"bot_like": false,}],"is_bot_like": false,"branches":["branch1"],"issues_codes":["PRJ-002","PRJ-003"],"issues_links":["https://jira.company.org/PRJ-002","https://jira.company.org/PRJ-003"]}