Use previous license term for seat overage
What does this MR do?
Part of #281177 (closed)
To get the current seat overage the historical max data is pulled for the past year. But not every license runs for a year. There was also an overlap for new licenses to the old one which was removed with https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/2635.
This change will take a previous license's term to pull the historical max data and only use the past year as a fallback.
How to test
In LicenseDot:
- Create a license with a start date of 2019-02-15 and and expiration date of 2020-02-15
- Create another license with a start date of 2020-02-01 and and expiration date of 2021-02-15
In GitLab:
- Create a
HistoricalData
entry for 100 users and setrecorded_at
to 2019-02-12 - Create another
HistoricalData
entry for 50 users and setrecorded_at
to 2019-02-13
In the rails console:
- Without the changes:
- Call
License.current.send(:prior_historical_max)
- See that the query uses the period between the 2019-02-01 and 2020-02-01 (start date of the current license - 1 year and start date of the current license)
- Returns 100
- Call
- With the changes:
- Call
License.current.send(:prior_historical_max)
- See that the query uses the period between the 2019-02-15 and 2020-02-15 (start date and expiration date of the previous license)
- Returns 0 (when no data exists for that period otherwise the max entry from that period but not the 100 as previously)
- Call
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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 Corinna Gogolok