BREAKS BUILD: all pages etc are much faster, but categories functionality is broken (it was responsible for calling the renderer once per every page on All Pages)

This commit is contained in:
Alexey Verkhovsky 2005-09-11 09:34:41 +00:00
parent 541a5d3994
commit ac819d4d68
4 changed files with 8 additions and 3 deletions

View file

@ -291,7 +291,9 @@ class WikiController < ApplicationController
@category = @params['category'] @category = @params['category']
@categories = [] @categories = []
@pages_in_category = @web.select do |page| @pages_in_category = @web.select do |page|
page_categories = PageRenderer.new(page.revisions.last).display_content.find_chunks(Category) # FIXME: was PageRenderer.new(page.revisions.last).display_content.find_chunks(Category),
# heinously slow
page_categories = []
page_categories = page_categories.map { |cat| cat.list }.flatten page_categories = page_categories.map { |cat| cat.list }.flatten
page_categories.each {|c| @categories << c unless @categories.include? c } page_categories.each {|c| @categories << c unless @categories.include? c }
page_categories.include?(@category) page_categories.include?(@category)

View file

@ -81,7 +81,9 @@ class PageSet < Array
end end
def wiki_words def wiki_words
self.inject([]) { |wiki_words, page| WikiReference.wiki_words(page) }.flatten.uniq self.inject([]) { |wiki_words, page|
wiki_words + page.wiki_references.map { |ref| ref.referenced_page_name }
}.flatten.uniq
end end
def authors def authors

View file

@ -1,5 +1,5 @@
class Web < ActiveRecord::Base class Web < ActiveRecord::Base
has_many :pages#, :include => [:current_revision, :web] has_many :pages
def wiki def wiki
Wiki.new Wiki.new

View file

@ -88,6 +88,7 @@ class PageRenderer
def render(options = {}) def render(options = {})
result = WikiContent.new(@revision, @@url_generator, options).render! result = WikiContent.new(@revision, @@url_generator, options).render!
WikiReference.delete_all ['page_id = ?', @revision.page_id]
@revision.page.wiki_references.delete @revision.page.wiki_references.delete
wiki_word_chunks = result.find_chunks(WikiChunk::WikiLink) wiki_word_chunks = result.find_chunks(WikiChunk::WikiLink)