Skip to content

Productivity Analytics: Add deep links (BE only)

Martin Wortschack requested to merge mw-pa-deep-links into master

What does this MR do?

  • BE task for adding deep links to the PA page.
  • FE is being implemented in !21390 (merged)
    • Changelog entry will be added in this MR.

How

  1. User goes to productivity analytics page and selects specific filters.
  2. User bookmarks the page to easily "load" the selected filters.
  3. When the user clicks on the bookmarked link the backend does the following:
    1. Process/cast all input parameters that are given with the initial HTML request.
    2. Validate the parameters.
    3. If the parameters are valid: expose them via HTML data attributes, so the frontend can process them.
    4. If the parameters are invalid: do nothing, expose only the safe, default values: merged_at_after and merged_at_before parameters.

Implementation

  • For the validation we're using ActiveModel since it has capabilities to cast attributes and provide standard error messages. We do similar validation for the cycle analytics feature.
  • ActiveModel also supports adding custom validation rules: date_1 attr should be earlier than date_2 attr.
  • For the initial HTML request the page should always load, even if the parameters are invalid (have fallback).
  • For the API requests (JSON) we must always validate the params and return 422, if the given parameters are invalid.
    • Note: the error messages are mainly for the frontend developers to easily debug problems, by default we expect that the frontend will always pass correct parameters.

Screenshots

data_attrs

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Adam Hegyi

Merge request reports