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
else
link_to event_note_target_path(event) 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
......
......@@ -16,6 +16,7 @@ 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) }
......@@ -25,7 +26,6 @@ module Issuable
scope :unassigned, -> { where("assignee_id IS NULL") }
scope :of_projects, ->(ids) { where(project_id: ids) }
validate :set_iid, on: :create
delegate :name,
:email,
......
......@@ -284,6 +284,14 @@ class Event < ActiveRecord::Base
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?
target.noteable_type.blank?
end
......
......@@ -23,7 +23,7 @@
%li
merge request:
= link_to [merge_request.target_project, merge_request] do
%span ##{merge_request.id}
%span ##{merge_request.iid}
%strong.term
= truncate merge_request.title, length: 50
- if merge_request.for_fork?
......@@ -37,7 +37,7 @@
%li
issue:
= link_to [issue.project, issue] do
%span ##{issue.id}
%span ##{issue.iid}
%strong.term
= truncate issue.title, length: 50
%span.light (#{issue.project.name_with_namespace})
......
......@@ -4,7 +4,7 @@ task migrate_iids: :environment do
Issue.where(iid: nil).find_each(batch_size: 100) do |issue|
begin
issue.set_iid
if issue.save
if issue.update_attribute(:iid, mr.iid)
print '.'
else
print 'F'
......@@ -19,7 +19,7 @@ task migrate_iids: :environment do
MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr|
begin
mr.set_iid
if mr.save
if mr.update_attribute(:iid, mr.iid)
print '.'
else
print 'F'
......@@ -28,4 +28,6 @@ task migrate_iids: :environment do
print 'F'
end
end
puts 'done'
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