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
e92a940d
Commit
e92a940d
authored
Aug 24, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a broken background migration spec due to a missing column
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
2e1fa146
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
app/models/project_statistics.rb
app/models/project_statistics.rb
+5
-1
spec/migrations/schedule_calculate_wiki_sizes_spec.rb
spec/migrations/schedule_calculate_wiki_sizes_spec.rb
+4
-4
No files found.
app/models/project_statistics.rb
View file @
e92a940d
...
@@ -80,11 +80,15 @@ class ProjectStatistics < ApplicationRecord
...
@@ -80,11 +80,15 @@ class ProjectStatistics < ApplicationRecord
end
end
def
update_storage_size
def
update_storage_size
storage_size
=
repository_size
+
wiki_size
+
lfs_objects_size
+
build_artifacts_size
+
packages_size
+
pipeline_artifacts_size
storage_size
=
repository_size
+
wiki_size
+
lfs_objects_size
+
build_artifacts_size
+
packages_size
# The `snippets_size` column was added on 20200622095419 but db/post_migrate/20190527194900_schedule_calculate_wiki_sizes.rb
# The `snippets_size` column was added on 20200622095419 but db/post_migrate/20190527194900_schedule_calculate_wiki_sizes.rb
# might try to update project statistics before the `snippets_size` column has been created.
# might try to update project statistics before the `snippets_size` column has been created.
storage_size
+=
snippets_size
if
self
.
class
.
column_names
.
include?
(
'snippets_size'
)
storage_size
+=
snippets_size
if
self
.
class
.
column_names
.
include?
(
'snippets_size'
)
# The `pipeline_artifacts_size` column was added on 20200817142800 but db/post_migrate/20190527194900_schedule_calculate_wiki_sizes.rb
# might try to update project statistics before the `pipeline_artifacts_size` column has been created.
storage_size
+=
pipeline_artifacts_size
if
self
.
class
.
column_names
.
include?
(
'pipeline_artifacts_size'
)
self
.
storage_size
=
storage_size
self
.
storage_size
=
storage_size
end
end
...
...
spec/migrations/schedule_calculate_wiki_sizes_spec.rb
View file @
e92a940d
...
@@ -16,9 +16,9 @@ RSpec.describe ScheduleCalculateWikiSizes do
...
@@ -16,9 +16,9 @@ RSpec.describe ScheduleCalculateWikiSizes do
let
(
:project3
)
{
projects
.
create!
(
name:
'wiki-project-3'
,
path:
'wiki-project-3'
,
namespace_id:
namespace
.
id
)
}
let
(
:project3
)
{
projects
.
create!
(
name:
'wiki-project-3'
,
path:
'wiki-project-3'
,
namespace_id:
namespace
.
id
)
}
context
'when missing wiki sizes exist'
do
context
'when missing wiki sizes exist'
do
let!
(
:project_statistic1
)
{
project_statistics
.
create!
(
id:
1
,
project_id:
project1
.
id
,
namespace_id:
namespace
.
id
,
wiki_size:
1000
)
}
let!
(
:project_statistic1
)
{
project_statistics
.
create!
(
project_id:
project1
.
id
,
namespace_id:
namespace
.
id
,
wiki_size:
1000
)
}
let!
(
:project_statistic2
)
{
project_statistics
.
create!
(
id:
2
,
project_id:
project2
.
id
,
namespace_id:
namespace
.
id
,
wiki_size:
nil
)
}
let!
(
:project_statistic2
)
{
project_statistics
.
create!
(
project_id:
project2
.
id
,
namespace_id:
namespace
.
id
,
wiki_size:
nil
)
}
let!
(
:project_statistic3
)
{
project_statistics
.
create!
(
id:
3
,
project_id:
project3
.
id
,
namespace_id:
namespace
.
id
,
wiki_size:
nil
)
}
let!
(
:project_statistic3
)
{
project_statistics
.
create!
(
project_id:
project3
.
id
,
namespace_id:
namespace
.
id
,
wiki_size:
nil
)
}
it
'schedules a background migration'
do
it
'schedules a background migration'
do
Timecop
.
freeze
do
Timecop
.
freeze
do
...
@@ -44,7 +44,7 @@ RSpec.describe ScheduleCalculateWikiSizes do
...
@@ -44,7 +44,7 @@ RSpec.describe ScheduleCalculateWikiSizes do
before
do
before
do
namespace
=
namespaces
.
create!
(
name:
'wiki-migration'
,
path:
'wiki-migration'
)
namespace
=
namespaces
.
create!
(
name:
'wiki-migration'
,
path:
'wiki-migration'
)
project
=
projects
.
create!
(
name:
'wiki-project-1'
,
path:
'wiki-project-1'
,
namespace_id:
namespace
.
id
)
project
=
projects
.
create!
(
name:
'wiki-project-1'
,
path:
'wiki-project-1'
,
namespace_id:
namespace
.
id
)
project_statistics
.
create!
(
project_id:
project
.
id
,
namespace_id:
1
,
wiki_size:
1000
)
project_statistics
.
create!
(
project_id:
project
.
id
,
namespace_id:
namespace
.
id
,
wiki_size:
1000
)
end
end
it
'does not schedule a background migration'
do
it
'does not schedule a background migration'
do
...
...
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