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
625fb2f2
Commit
625fb2f2
authored
Aug 21, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add iids to milestones. Moved iids logic to separate concern
parent
0a0b0e1e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
14 deletions
+43
-14
app/models/concerns/internal_id.rb
app/models/concerns/internal_id.rb
+17
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+0
-11
app/models/issue.rb
app/models/issue.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/models/milestone.rb
app/models/milestone.rb
+2
-0
db/migrate/20130821090531_add_internal_ids_to_milestones.rb
db/migrate/20130821090531_add_internal_ids_to_milestones.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
lib/tasks/migrate/migrate_iids.rake
lib/tasks/migrate/migrate_iids.rake
+15
-0
No files found.
app/models/concerns/internal_id.rb
0 → 100644
View file @
625fb2f2
module
InternalId
extend
ActiveSupport
::
Concern
included
do
validate
:set_iid
,
on: :create
validates
:iid
,
presence:
true
,
numericality:
true
end
def
set_iid
max_iid
=
project
.
send
(
self
.
class
.
name
.
tableize
).
maximum
(
:iid
)
self
.
iid
=
max_iid
.
to_i
+
1
end
def
to_param
iid
.
to_s
end
end
app/models/concerns/issuable.rb
View file @
625fb2f2
...
...
@@ -16,8 +16,6 @@ module Issuable
validates
:author
,
presence:
true
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validate
:set_iid
,
on: :create
validates
:iid
,
presence:
true
,
numericality:
true
scope
:authored
,
->
(
user
)
{
where
(
author_id:
user
)
}
scope
:assigned_to
,
->
(
u
)
{
where
(
assignee_id:
u
.
id
)}
...
...
@@ -47,15 +45,6 @@ module Issuable
end
end
def
set_iid
max_iid
=
project
.
send
(
self
.
class
.
name
.
tableize
).
maximum
(
:iid
)
self
.
iid
=
max_iid
.
to_i
+
1
end
def
to_param
iid
.
to_s
end
def
today?
Date
.
today
==
created_at
.
to_date
end
...
...
app/models/issue.rb
View file @
625fb2f2
...
...
@@ -17,8 +17,8 @@
#
class
Issue
<
ActiveRecord
::
Base
include
Issuable
include
InternalId
belongs_to
:project
validates
:project
,
presence:
true
...
...
app/models/merge_request.rb
View file @
625fb2f2
...
...
@@ -23,8 +23,8 @@ require Rails.root.join("app/models/commit")
require
Rails
.
root
.
join
(
"lib/static_model"
)
class
MergeRequest
<
ActiveRecord
::
Base
include
Issuable
include
InternalId
belongs_to
:target_project
,
foreign_key: :target_project_id
,
class_name:
"Project"
belongs_to
:source_project
,
foreign_key: :source_project_id
,
class_name:
"Project"
...
...
app/models/milestone.rb
View file @
625fb2f2
...
...
@@ -13,6 +13,8 @@
#
class
Milestone
<
ActiveRecord
::
Base
include
InternalId
attr_accessible
:title
,
:description
,
:due_date
,
:state_event
,
:author_id_of_changes
attr_accessor
:author_id_of_changes
...
...
db/migrate/20130821090531_add_internal_ids_to_milestones.rb
0 → 100644
View file @
625fb2f2
class
AddInternalIdsToMilestones
<
ActiveRecord
::
Migration
def
change
add_column
:milestones
,
:iid
,
:integer
end
end
db/schema.rb
View file @
625fb2f2
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
2013082109053
0
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
2013082109053
1
)
do
create_table
"deploy_keys_projects"
,
:force
=>
true
do
|
t
|
t
.
integer
"deploy_key_id"
,
:null
=>
false
...
...
@@ -119,6 +119,7 @@ ActiveRecord::Schema.define(:version => 20130821090530) do
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
string
"state"
t
.
integer
"iid"
end
add_index
"milestones"
,
[
"due_date"
],
:name
=>
"index_milestones_on_due_date"
...
...
lib/tasks/migrate/migrate_iids.rake
View file @
625fb2f2
...
...
@@ -29,5 +29,20 @@ task migrate_iids: :environment do
end
end
puts
'done'
puts
'Milestones'
.
yellow
Milestone
.
where
(
iid:
nil
).
find_each
(
batch_size:
100
)
do
|
m
|
begin
m
.
set_iid
if
m
.
update_attribute
(
:iid
,
m
.
iid
)
print
'.'
else
print
'F'
end
rescue
print
'F'
end
end
puts
'done'
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