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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
d10b34a6
Commit
d10b34a6
authored
May 02, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save repository size to projects table
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
87c397f5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
2 deletions
+34
-2
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+1
-1
app/models/project.rb
app/models/project.rb
+4
-0
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-0
db/migrate/20140502115131_add_repo_size_to_db.rb
db/migrate/20140502115131_add_repo_size_to_db.rb
+5
-0
db/migrate/20140502125220_migrate_repo_size.rb
db/migrate/20140502125220_migrate_repo_size.rb
+21
-0
db/schema.rb
db/schema.rb
+2
-1
No files found.
app/helpers/projects_helper.rb
View file @
d10b34a6
...
...
@@ -163,7 +163,7 @@ module ProjectsHelper
end
def
repository_size
(
project
=
nil
)
"
#{
(
project
||
@project
).
repository
.
size
}
MB"
"
#{
(
project
||
@project
).
repository
_
size
}
MB"
rescue
# In order to prevent 500 error
# when application cannot allocate memory
...
...
app/models/project.rb
View file @
d10b34a6
...
...
@@ -562,4 +562,8 @@ class Project < ActiveRecord::Base
def
forked_from?
(
project
)
forked?
&&
project
==
forked_from_project
end
def
update_repository_size
update_attribute
(
:repository_size
,
repository
.
size
)
end
end
app/services/git_push_service.rb
View file @
d10b34a6
...
...
@@ -25,6 +25,7 @@ class GitPushService
project
.
ensure_satellite_exists
project
.
repository
.
expire_cache
project
.
update_repository_size
if
push_to_existing_branch?
(
ref
,
oldrev
)
project
.
update_merge_requests
(
oldrev
,
newrev
,
ref
,
@user
)
...
...
db/migrate/20140502115131_add_repo_size_to_db.rb
0 → 100644
View file @
d10b34a6
class
AddRepoSizeToDb
<
ActiveRecord
::
Migration
def
change
add_column
:projects
,
:repository_size
,
:float
,
default:
0
end
end
db/migrate/20140502125220_migrate_repo_size.rb
0 → 100644
View file @
d10b34a6
class
MigrateRepoSize
<
ActiveRecord
::
Migration
def
up
Project
.
reset_column_information
Project
.
find_each
(
batch_size:
500
)
do
|
project
|
begin
if
project
.
empty_repo?
print
'-'
else
project
.
update_repository_size
print
'.'
end
rescue
print
'F'
end
end
puts
'Done'
end
def
down
end
end
db/schema.rb
View file @
d10b34a6
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20140
428105831
)
do
ActiveRecord
::
Schema
.
define
(
version:
20140
502125220
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -222,6 +222,7 @@ ActiveRecord::Schema.define(version: 20140428105831) do
t
.
integer
"visibility_level"
,
default:
0
,
null:
false
t
.
boolean
"archived"
,
default:
false
,
null:
false
t
.
string
"import_status"
t
.
float
"repository_size"
,
default:
0.0
end
add_index
"projects"
,
[
"creator_id"
],
name:
"index_projects_on_creator_id"
,
using: :btree
...
...
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