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
18003129
Commit
18003129
authored
Oct 08, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More realistic instance statistics fixtures
parent
d63a0234
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
db/fixtures/development/29_instance_statistics.rb
db/fixtures/development/29_instance_statistics.rb
+20
-6
No files found.
db/fixtures/development/29_instance_statistics.rb
View file @
18003129
...
...
@@ -3,17 +3,31 @@
require
'./spec/support/sidekiq_middleware'
Gitlab
::
Seeder
.
quiet
do
chance_for_decrement
=
0.1
# 10% chance that we'll generate smaller count than the previous count
max_increase
=
10000
max_decrease
=
1000
model_class
=
Analytics
::
InstanceStatistics
::
Measurement
recorded_at
=
Date
.
today
# Insert random counts for the last 60 days
measurements
=
60
.
times
.
flat_map
do
recorded_at
=
(
recorded_at
-
1
.
day
).
end_of_day
-
5
.
minutes
measurements
=
model_class
.
identifiers
.
flat_map
do
|
_
,
id
|
recorded_at
=
60
.
days
.
ago
current_count
=
rand
(
1_000_000
)
# Insert random counts for the last 60 days
Array
.
new
(
60
)
do
recorded_at
=
(
recorded_at
+
1
.
day
).
end_of_day
-
5
.
minutes
# Normally our counts should slowly increase as the gitlab instance grows.
# Small chance (10%) to have a slight decrease (simulating cleanups, bulk delete)
if
rand
<
chance_for_decrement
current_count
-=
rand
(
max_decrease
)
else
current_count
+=
rand
(
max_increase
)
end
model_class
.
identifiers
.
map
do
|
_
,
id
|
{
recorded_at:
recorded_at
,
count:
rand
(
1_000_000
)
,
count:
current_count
,
identifier:
id
}
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