Commit 34bea73f authored by Corinna Wiesner's avatar Corinna Wiesner

Convert timestamps to utc in license usage export

Prior to this change, the timestamps included in the license usage file
that can be exported on the subscription page did not include any
timezone information. This change will ensure that the included
timestamps are converted to utc.

Changelog: changed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79832
EE: true
parent 1082e32a
......@@ -11,7 +11,7 @@ This document lists the different implementations of CSV export in GitLab codeba
| Export type | How it works | Advantages | Disadvantages | Existing examples |
|---|---|---|---|---|
| Streaming | - Query and yield data in batches to a response stream.<br>- Download starts immediately. | - Report available immediately. | - No progress indicator.<br>- Requires a reliable connection. | [Export Audit Event Log](../administration/audit_events.md#export-to-csv) |
| Downloading | - Query and write data in batches to a temporary file.<br>- Loads the file into memory.<br>- Sends the file to the client. | - Report available immediately. | - Large amount of data might cause request timeout.<br>- Memory intensive.<br>- Request expires when user navigates to a different page. | [Export Chain of Custody Report](../user/compliance/compliance_report/#chain-of-custody-report) |
| Downloading | - Query and write data in batches to a temporary file.<br>- Loads the file into memory.<br>- Sends the file to the client. | - Report available immediately. | - Large amount of data might cause request timeout.<br>- Memory intensive.<br>- Request expires when user navigates to a different page. | - [Export Chain of Custody Report](../user/compliance/compliance_report/#chain-of-custody-report)<br>- [Export License Usage File](../subscriptions/self_managed/index.md#export-your-license-usage) |
| As email attachment | - Asynchronously process the query with background job.<br>- Email uses the export as an attachment. | - Asynchronous processing. | - Requires users use a different app (email) to download the CSV.<br>- Email providers may limit attachment size. | - [Export issues](../user/project/issues/csv_export.md)<br>- [Export merge requests](../user/project/merge_requests/csv_export.md) |
| As downloadable link in email (*) | - Asynchronously process the query with background job.<br>- Email uses an export link. | - Asynchronous processing.<br>- Bypasses email provider attachment size limit. | - Requires users use a different app (email).<br>- Requires additional storage and cleanup. | [Export User Permissions](https://gitlab.com/gitlab-org/gitlab/-/issues/1772) |
| Polling (non-persistent state) | - Asynchronously processes the query with the background job.<br>- Frontend(FE) polls every few seconds to check if CSV file is ready. | - Asynchronous processing.<br>- Automatically downloads to local machine on completion.<br>- In-app solution. | - Non-persistable request - request expires when user navigates to a different page.<br>- API is processed for each polling request. | [Export Vulnerabilities](../user/application_security/vulnerability_report/#export-vulnerability-details) |
......
......@@ -309,6 +309,11 @@ The **License Usage** CSV includes the following details:
- Date the count was recorded
- Active user count
NOTES:
- All timestamps are displayed in UTC.
- A custom format is used for [dates](https://gitlab.com/gitlab-org/gitlab/blob/3be39f19ac3412c089be28553e6f91b681e5d739/config/initializers/date_time_formats.rb#L7) and [times](https://gitlab.com/gitlab-org/gitlab/blob/3be39f19ac3412c089be28553e6f91b681e5d739/config/initializers/date_time_formats.rb#L13) in CSV files.
## Renew your subscription
To renew your subscription,
......
......@@ -128,6 +128,8 @@ the current date range is the active license.
When you upload a future-dated license, it doesn't take effect until its applicable date.
You can view all active subscriptions in the **Subscription history** table.
You can also [export](../../subscriptions/self_managed/index.md) your license usage information to a CSV file.
NOTE:
In GitLab 13.6 and earlier, a banner about an expiring license may continue to display
when you upload a new license. This happens when the start date of the new license
......
......@@ -22,7 +22,7 @@ module HistoricalUserData
def header_to_value_hash
{
'Date' => -> (historical_datum) { historical_datum.recorded_at.to_s(:csv) },
'Date' => -> (historical_datum) { historical_datum.recorded_at.utc.to_s(:csv) },
'Active User Count' => 'active_user_count'
}
end
......@@ -38,7 +38,7 @@ module HistoricalUserData
csv << ['License Start Date', license.starts_at&.to_s(:csv)]
csv << ['License End Date', license.expires_at&.to_s(:csv)]
csv << ['Company', license.licensee_company]
csv << ['Generated At', Time.current.to_s(:csv)]
csv << ['Generated At', Time.current.utc.to_s(:csv)]
csv << ['', '']
end
end
......
......@@ -87,7 +87,7 @@ RSpec.describe HistoricalUserData::CsvService do
end
it 'shows the CSV generation time' do
expect(csv[5][1]).to eq(datetime.to_s(:csv))
expect(csv[5][1]).to eq(datetime.utc.to_s(:csv))
end
end
end
......@@ -114,11 +114,11 @@ RSpec.describe HistoricalUserData::CsvService do
it 'includes proper values for each column type', :aggregate_failures do
expect(csv[8]).to contain_exactly(
historical_datum.recorded_at.to_s(:db),
historical_datum.recorded_at.utc.to_s(:csv),
historical_datum.active_user_count.to_s
)
expect(csv[9]).to contain_exactly(
historical_datum2.recorded_at.to_s(:db),
historical_datum2.recorded_at.utc.to_s(:csv),
historical_datum2.active_user_count.to_s
)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment