Commit 434c0341 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Iid improvemets

* call set_iid before validation
* make rake task pass event if objects are invalid
* show iid in comment event at dashboard
parent 20397091
...@@ -109,7 +109,7 @@ module EventsHelper ...@@ -109,7 +109,7 @@ module EventsHelper
else else
link_to event_note_target_path(event) do link_to event_note_target_path(event) do
content_tag :strong do content_tag :strong do
"#{event.note_target_type} ##{truncate event.note_target_id}" "#{event.note_target_type} ##{truncate event.note_target_iid}"
end end
end end
end end
......
...@@ -16,6 +16,7 @@ module Issuable ...@@ -16,6 +16,7 @@ module Issuable
validates :author, presence: true validates :author, presence: true
validates :title, presence: true, length: { within: 0..255 } validates :title, presence: true, length: { within: 0..255 }
validate :set_iid, on: :create
validates :iid, presence: true, numericality: true validates :iid, presence: true, numericality: true
scope :authored, ->(user) { where(author_id: user) } scope :authored, ->(user) { where(author_id: user) }
...@@ -25,7 +26,6 @@ module Issuable ...@@ -25,7 +26,6 @@ module Issuable
scope :unassigned, -> { where("assignee_id IS NULL") } scope :unassigned, -> { where("assignee_id IS NULL") }
scope :of_projects, ->(ids) { where(project_id: ids) } scope :of_projects, ->(ids) { where(project_id: ids) }
validate :set_iid, on: :create
delegate :name, delegate :name,
:email, :email,
......
...@@ -284,6 +284,14 @@ class Event < ActiveRecord::Base ...@@ -284,6 +284,14 @@ class Event < ActiveRecord::Base
end end
end end
def note_target_iid
if note_target.respond_to?(:iid)
note_target.iid
else
note_target_id
end.to_s
end
def wall_note? def wall_note?
target.noteable_type.blank? target.noteable_type.blank?
end end
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
%li %li
merge request: merge request:
= link_to [merge_request.target_project, merge_request] do = link_to [merge_request.target_project, merge_request] do
%span ##{merge_request.id} %span ##{merge_request.iid}
%strong.term %strong.term
= truncate merge_request.title, length: 50 = truncate merge_request.title, length: 50
- if merge_request.for_fork? - if merge_request.for_fork?
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
%li %li
issue: issue:
= link_to [issue.project, issue] do = link_to [issue.project, issue] do
%span ##{issue.id} %span ##{issue.iid}
%strong.term %strong.term
= truncate issue.title, length: 50 = truncate issue.title, length: 50
%span.light (#{issue.project.name_with_namespace}) %span.light (#{issue.project.name_with_namespace})
......
...@@ -4,7 +4,7 @@ task migrate_iids: :environment do ...@@ -4,7 +4,7 @@ task migrate_iids: :environment do
Issue.where(iid: nil).find_each(batch_size: 100) do |issue| Issue.where(iid: nil).find_each(batch_size: 100) do |issue|
begin begin
issue.set_iid issue.set_iid
if issue.save if issue.update_attribute(:iid, mr.iid)
print '.' print '.'
else else
print 'F' print 'F'
...@@ -19,7 +19,7 @@ task migrate_iids: :environment do ...@@ -19,7 +19,7 @@ task migrate_iids: :environment do
MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr| MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr|
begin begin
mr.set_iid mr.set_iid
if mr.save if mr.update_attribute(:iid, mr.iid)
print '.' print '.'
else else
print 'F' print 'F'
...@@ -28,4 +28,6 @@ task migrate_iids: :environment do ...@@ -28,4 +28,6 @@ task migrate_iids: :environment do
print 'F' print 'F'
end end
end end
puts 'done'
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment