On Thu, Feb 21, 2008 at 4:52 AM, Andrew Garrett andrew@epstone.net wrote:
So, if I were to implement this tomorrow, this is what I would do (feedback welcomed):
- Create a 'category' table starting off with a c_id, c_page_id, and
c_count. This would fit in very nicely with something Tim was talking about last night - allowing flags to be put on categories (i.e. "don't show this category on the article", "show icon Image:X in the top corner of articles in this category", et cetera) which could be put in a separate column of the category table.
- On save of a category, or a page including that category, insert the
requisite category entry (this would save a dirty great big migration script).
- When a categorylinks item is INSERTED or DELETED on links-update
(the code is nice in that it only inserts/deletes those items which have been added/removed), do the requisite incrementing/decrementing on the category table.
- Display the count on the category page.
What about the number of items in different namespaces? At the very least, I'd like to separate pages and files in the count. Maybe also articles and other namespaces, so there'd be c_count_main, c_count_files, c_count_other.
This would add a performance penalty of a potentially very expensive database query per category, as a once-off, on page-save. It would enable a whole bunch of new functionality, such as proper display of membership counts on category pages, the stuff Tim was talking about last night with assigning a bit of metadata to categories (to make them a bit more useful).
Hmm... When you save a page, there can only be three "changes" regarding a category: 1. It was added 2. It was removed 3. It was kept
#3 won't cost anything; #1 and #2 could be solved by increasing/decreasing the counter.
Not sure about long-term consitency (update cronjob?) and template edits (changing categories for lots'o'pages).
I'm willing to look into implementing this in the next few months, depending upon how my understanding of the technical details corresponds to reality.
Great!
Magnus