Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
26d8cd51
Commit
26d8cd51
authored
Sep 01, 2020
by
Alan (Maciej) Paruszewski
Committed by
Mayra Cabrera
Sep 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand retention period to 365 days for Vulnerability Statistics
parent
fdc00989
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
14 deletions
+21
-14
ee/app/services/vulnerabilities/historical_statistics/deletion_service.rb
...vulnerabilities/historical_statistics/deletion_service.rb
+3
-1
ee/changelogs/unreleased/235630-expand-retention-period-to-1-year-for-vulnerability-statistics.yml
...tention-period-to-1-year-for-vulnerability-statistics.yml
+5
-0
ee/spec/services/vulnerabilities/historical_statistics/deletion_service_spec.rb
...rabilities/historical_statistics/deletion_service_spec.rb
+13
-13
No files found.
ee/app/services/vulnerabilities/historical_statistics/deletion_service.rb
View file @
26d8cd51
...
...
@@ -3,13 +3,15 @@
module
Vulnerabilities
module
HistoricalStatistics
class
DeletionService
RETENTION_PERIOD_IN_DAYS
=
365
def
self
.
execute
new
.
execute
end
def
execute
::
Vulnerabilities
::
HistoricalStatistic
.
older_than
(
days:
100
)
.
older_than
(
days:
RETENTION_PERIOD_IN_DAYS
)
.
each_batch
{
|
relation
|
relation
.
delete_all
}
end
end
...
...
ee/changelogs/unreleased/235630-expand-retention-period-to-1-year-for-vulnerability-statistics.yml
0 → 100644
View file @
26d8cd51
---
title
:
Expand retention period to 365 days for Vulnerability Statistics
merge_request
:
40833
author
:
type
:
changed
ee/spec/services/vulnerabilities/historical_statistics/deletion_service_spec.rb
View file @
26d8cd51
...
...
@@ -30,35 +30,35 @@ RSpec.describe Vulnerabilities::HistoricalStatistics::DeletionService do
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
25
.
days
.
ago
)
end
context
'when there is no historical statistics older than
100
days'
do
context
'when there is no historical statistics older than
365
days'
do
it
'does not delete historical statistics'
do
expect
{
delete_historical_statistics
}.
not_to
change
{
Vulnerabilities
::
HistoricalStatistic
.
count
}
end
end
context
'when there is a historical statistic entry that was created
99
days ago'
do
context
'when there is a historical statistic entry that was created
364
days ago'
do
before
do
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
99
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
99
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
364
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
364
.
days
.
ago
)
end
it
'does not delete historical statistics'
do
expect
{
delete_historical_statistics
}.
not_to
change
{
Vulnerabilities
::
HistoricalStatistic
.
count
}
end
context
'and there are more than one entries that are older than
100
days'
do
context
'and there are more than one entries that are older than
365
days'
do
before
do
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
101
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
102
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
103
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
101
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
102
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
103
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
366
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
367
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
project
,
date:
368
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
366
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
367
.
days
.
ago
)
create
(
:vulnerability_historical_statistic
,
project:
other_project
,
date:
368
.
days
.
ago
)
end
it
'deletes historical statistics older than
90
days'
,
:aggregate_failures
do
it
'deletes historical statistics older than
365
days'
,
:aggregate_failures
do
expect
{
delete_historical_statistics
}.
to
change
{
Vulnerabilities
::
HistoricalStatistic
.
count
}.
by
(
-
6
)
expect
(
Vulnerabilities
::
HistoricalStatistic
.
pluck
(
:date
)).
to
all
(
be
>=
100
.
days
.
ago
.
to_date
)
expect
(
Vulnerabilities
::
HistoricalStatistic
.
pluck
(
:date
)).
to
all
(
be
>=
365
.
days
.
ago
.
to_date
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment