alias_and_implication_list: refactor alias/implication lookup.

Add alias and implications associations to Tag. Use them in
alias_and_implication list instead of duplicating the alias/implication
lookup code.
This commit is contained in:
evazion
2017-03-23 02:43:55 -05:00
parent b3e3012a9c
commit 0793beded9
5 changed files with 17 additions and 37 deletions

View File

@@ -13,22 +13,6 @@ class WikiPagePresenter
DText.strip(excerpt.to_s)
end
def consequent_tag_aliases
@consequent_tag_aliases ||= TagAlias.where("status in ('active', 'processing') and consequent_name = ?", wiki_page.title)
end
def antecedent_tag_alias
@antecedent_tag_alias ||= TagAlias.where("status in ('active', 'processing') and antecedent_name = ?", wiki_page.title).first
end
def consequent_tag_implications
@consequent_tag_implications ||= TagImplication.where("status in ('active', 'processing') and consequent_name = ?", wiki_page.title)
end
def antecedent_tag_implications
@antecedent_tag_implications ||= TagImplication.where("status in ('active', 'processing') and antecedent_name = ?", wiki_page.title)
end
# Produce a formatted page that shows the difference between two versions of a page.
def diff(other_version)
pattern = Regexp.new('(?:<.+?>)|(?:[0-9_A-Za-z\x80-\xff]+[\x09\x20]?)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')