Modify

Opened 17 years ago

Closed 17 years ago

Last modified 11 years ago

#1877 closed enhancement (fixed)

Take only last version of wiki pages

Reported by: ebzao+trac@… Owned by: anonymous
Priority: normal Component: WantedPagesMacro
Severity: minor Keywords:
Cc: Trac Release: 0.10

Description

Hi,

I've made this little patch to take only last version of wiki pages when searching for wanted pages. I think it's non-sense to make links used only in old version of wiki pages.

Perhaps there is a better SQL query to have this, I haven't found it ;-)

Index: wanted_pages.py
===================================================================
--- wanted_pages.py     (révision 2539)
+++ wanted_pages.py     (copie de travail)
@@ -13,7 +13,7 @@
 fancy_re = re.compile(FANCY)
 exclude_re = re.compile(EXCLUDE)

-wiki_sql = "SELECT name, text FROM wiki ORDER BY version"
+wiki_sql = "SELECT name, text FROM wiki ORDER BY version DESC"
 ticket_sql= """SELECT id, description FROM ticket
     UNION
     SELECT ticket, newvalue FROM ticket_change WHERE field='comment'
@@ -55,11 +55,14 @@
     def buildWikiText(self, showReferrers=False):
         texts = [] # list of referrer link, wiki-able text tuples
         wantedPages = {} # referrers indexed by page
+       wikiPages = [] # list of wikiPages seen
         db = self.env.get_db_cnx()

         for name, text in exec_wiki_sql(db):
-            self.index[name] = name
-            texts.append(('[wiki:%s]' % name, text))
+           if name not in wikiPages:
+              wikiPages.append(name)
+              self.index[name] = name
+              texts.append(('[wiki:%s]' % name, text))

         for id, text in exec_ticket_sql(db):
             texts.append(('#%s' % id, text))

Attachments (0)

Change History (5)

comment:1 Changed 17 years ago by Justin Francis

Owner: changed from Justin Francis to anonymous
Status: newassigned

Thanks for patch. I'll write some unit tests to expose the bug and integrate the patch in the next week.

comment:2 Changed 17 years ago by anonymous

Resolution: fixed
Status: assignedclosed

integrated in [2725]. It took a while, but hey, I'm lazy

comment:3 Changed 17 years ago by Kamil Kisiel

Resolution: fixed
Status: closedreopened

The implemented version is incorrect. The indentation level on the last two lines of the fix is wrong, so the plugin still adds all pages. Currently it looks like this:

if name not in wikiPages:
    wikiPages.append(name)
self.index[name] = name
texts.append(('[wiki:%s]' % name, text))

but it should look like this:

if name not in wikiPages:
    wikiPages.append(name)
    self.index[name] = name
    texts.append(('[wiki:%s]' % name, text))

comment:4 Changed 17 years ago by Justin Francis

Resolution: fixed
Status: reopenedclosed

Hmmmm. It appears it was my mistake. My editor inserted tabs when I needed space-tabs. There was a mixture of spaces and tabs that resulted in this code still running, but exactly was it was before.

In any case, it has been fixed in [2873]

comment:5 Changed 11 years ago by Ryan J Ollos

Component: WantedPagesPluginWantedPagesMacro

Renaming plugin from WantedPagesPlugin to WantedPagesMacro.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain anonymous.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.