fixes #858
adds color coding to both urls and other names on artist versions
This commit is contained in:
@@ -27,6 +27,36 @@ class ArtistVersion < ActiveRecord::Base
|
||||
url_string.scan(/\S+/)
|
||||
end
|
||||
|
||||
def other_names_array
|
||||
other_names.scan(/\S+/)
|
||||
end
|
||||
|
||||
def urls_diff(version)
|
||||
new_urls = url_array
|
||||
old_urls = version.present? ? version.url_array : []
|
||||
|
||||
return {
|
||||
:added_urls => new_urls - old_urls,
|
||||
:removed_urls => old_urls - new_urls,
|
||||
:unchanged_urls => new_urls & old_urls,
|
||||
}
|
||||
end
|
||||
|
||||
def other_names_diff(version)
|
||||
new_names = other_names_array
|
||||
old_names = version.present? ? version.other_names_array : []
|
||||
|
||||
return {
|
||||
:added_names => new_names - old_names,
|
||||
:removed_names => old_names - new_names,
|
||||
:unchanged_names => new_names & old_names,
|
||||
}
|
||||
end
|
||||
|
||||
def previous
|
||||
ArtistVersion.where("artist_id = ? and updated_at < ?", artist_id, updated_at).order("updated_at desc").first
|
||||
end
|
||||
|
||||
def updater_name
|
||||
User.id_to_name(updater_id).tr("_", " ")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user