adds color coding to both urls and other names on artist versions
This commit is contained in:
Toks
2013-03-29 09:59:14 -04:00
parent 30ba85d516
commit 7e3324b5f0
4 changed files with 62 additions and 5 deletions

View File

@@ -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