Archives plugin number of entries per category incorrect.

Found a bug? Tell us!!
Post Reply
aaronsignor
Regular
Posts: 5
Joined: Wed Jul 11, 2007 10:03 am

Archives plugin number of entries per category incorrect.

Post by aaronsignor »

Why even after refreshing my cache and reloading my browser, does the number of entries per category in the CATEGORIES plugin display incorrectly? Is there a way to fix this?

ALSO:

Is there a way to hide months with no posts???

-Aaron
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Archives plugin number of entries per category incorrect

Post by garvinhicking »

Hi!

Wow, you're yelling in red. :-D

Please give us your URL, then we can have a look at your problem.
Is there a way to hide months with no posts???
No, there currently is no way.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
aaronsignor
Regular
Posts: 5
Joined: Wed Jul 11, 2007 10:03 am

Okay thanks here is my information

Post by aaronsignor »

Sorry for yelling in red... that came out looking different than I had planned :-)

Here is my website:

http://photography.aaronsignor.net
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Okay thanks here is my information

Post by garvinhicking »

Hi!

Nice homepage you have there, we share the same hobby (and camera!) :-)

Can you tell me for which categories the count is wrong? I checked the two (Abstract and ARchitecture) and those only contained 2 postings, like the sidebar output shows?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
aaronsignor
Regular
Posts: 5
Joined: Wed Jul 11, 2007 10:03 am

actually I meant archives, not categories

Post by aaronsignor »

the problem is with the archives list. I am not sure maybe if something is out of synch with the database or maybe it is something with my server. I am using server 2003. The problem appears when using IE6 or Mozilla.

July 2007 (3) I only have two May items so far
June 2007 (2) I only have one June item so far
May 2007 (5) I only have two May items so far
April 2007 (1) I only have one April item so far
March 2007 (0)
February 2007 (0)
January 2007 (0)
December 2006 (0)
November 2006 (0)
October 2006 (2) I only have one October item so far
September 2006 (1)
August 2006 (0)
July 2006 (0)
June 2006 (0)
May 2006 (0)
April 2006 (0)
March 2006 (0)
February 2006 (2)
January 2006 (0)
December 2005 (0)
November 2005 (0)
October 2005 (0)
September 2005 (0)
August 2005 (0)
July 2005 (0)
June 2005 (0)
May 2005 (0)
April 2005 (0)
March 2005 (0)
February 2005 (0)
January 2005 (1)
December 2004 (0)
November 2004 (0)
October 2004 (0)
September 2004 (0)
August 2004 (0)
Recent...
Older...

So anyway, it looks like the count is wrong, unless I am totally overlooking something obvious?

anyhow, Serendipity is very impressive. I am really happy how I could get it to look exactly like I wanted. I found a website which I liked, and used Serendipity to mimic the design I preferred by editing the style.css file. I know this is off topic but here is the website I modeled mine after:
http://hkdigit.blogspot.com/ Thanks for making serendipity available.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: actually I meant archives, not categories

Post by garvinhicking »

Hi!

Ah, I understand. Sadly, indeed this is a bug that is hard to circument without dropping the performance completely to its knees.

The reason is, each article that you post is sometimes associated with more than one category. The archives plugin cannot find out, that these are single entries, and instead will count and build the sum of all articles in all categories, counting an entry in multiple categories multiple times.

The database query that creates this list is quite complex, and I have not found a way to properly count the entries without having huge redundancies. :(

Thanks though for your compliments about Serendipity! I'm really ashamed that I have to tell you about one of the very few shortcomings of the system. :(

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
aaronsignor
Regular
Posts: 5
Joined: Wed Jul 11, 2007 10:03 am

yes, one of very few shortcomings

Post by aaronsignor »

I understand, this stuff, including databases, can be very complicated. Yes, this would be one of very few shortcomings of the system. I really like the gzip feature also.

If there could be a way simply to exclude a month or week whose count numner has a value of zero, I could just turn off the count number and not bother with it. My main reason for using the numbering feature isn't so much so that the user can see how many possts there are for a month, but so that they can see that there ARE some. If the empty months were not displayed, this might be a roundabout solution. I hope I am making my point. Just trying to give feedback.

-Aaron

yes, and I am really taking a long time getting used to that Nikon D80... good camera though!
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Post by blog.brockha.us »

Hi Garvin.

This is produced by the joins inside of serendipity_fetchEntries.

If you change its signature to

Code: Select all

function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '', $noCache = false, $noSticky = false, $select_key = null, $group_by = null, $returncode = 'array',$joinauthors = true, $joinentrycat = true, $joincategory =true)
and change the sql in line 377 to

Code: Select all

    // Store the unique query condition for entries for later reference, like getting the total article count.
    $serendipity['fullCountQuery'] = "
                FROM
                    {$serendipity['dbPrefix']}entries AS e";
    if ($joinauthors)
        $serendipity['fullCountQuery'] .="
                    LEFT JOIN {$serendipity['dbPrefix']}authors a
                        ON e.authorid = a.authorid";
    if ($joinentrycat)
        $serendipity['fullCountQuery'] .="
                    LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
                        ON e.id = ec.entryid";
    if ($joincategory)
        $serendipity['fullCountQuery'] .="
                    LEFT JOIN {$serendipity['dbPrefix']}category c
                        ON ec.categoryid = c.categoryid";
    $serendipity['fullCountQuery'] .="
                    {$cond['joins']}
                    {$cond['and']}";

and after this in the plugin_internal change line 531 to

Code: Select all

                $ec = serendipity_fetchEntries(
                    array($current_ts, $end_ts),
                    false,
                    '',
                    false,
                    false,
                    'timestamp DESC',
                    '',
                    false,
                    true,
                    'count(e.id) AS orderkey',
                    '',
                    'single',
                    false,false,false // joins
                );
The archive shows the correct number of entries for a month/week/day.

Would this patch destroy something else, or should I comit this to the SVN?

P.S.: And btw: Adding an option for hiding 0 count month/week/days is very simple, too, I guess..
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Post by blog.brockha.us »

Oh! While testing this stuff, I noticed, that setting archives to "Kalenderintavall" weeks produces links, not working anymore. The sidabar plugin shows the correct amount of entries in a week, but if I clikck on the corresponding link I get a "no entry found" message.
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Post by blog.brockha.us »

Umpf.. The patch above crashes, if a category is selected.

It has to be changed like this:

Code: Select all


/ .. code ..

$category_set = isset($serendipity['GET']['category']);

/ .. code ..

                $ec = serendipity_fetchEntries(
                    array($current_ts, $end_ts),
                    false,
                    '',
                    false,
                    false,
                    'timestamp DESC',
                    '',
                    false,
                    true,
                    'count(e.id) AS orderkey',
                    '',
                    'single',
                    false,$category_set,$category_set // joins
                );
This still gives correct article amounts in normal and in category mode.
(..and pushes the performance for the archive plugin, as the joins are only pulled if needed)
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

I think this is a good suggestion. Because of possible side-effects, I'd only merge it to the SVN trunk, though.

I'm thinking if it's better to pull a single function signature $required_joins into the function, and then call:

Code: Select all

serendipity_fetchEntries(..., array());
for no joins and

Code: Select all

serendipity_fetchEntries(..., array('category', 'authors'));
for only category+author joins. The fetchEntries function could then set the defaulf array if the parameter is null. What do you think? If you like it, you can go ahead and commit the change. :)

Many thanks,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Post by blog.brockha.us »

I thought about this, too. But then I though it is more typo save and more easy to use 3 bool values with meaningfull names and description, as most IDEs should give the signature description - my IDE eclipse does at least.

If the parameter is just an array, where coders can put in anything, it doesn't look that stable to me.. What do you think? Perhaps another alternative, that didn't come into my mind?

And yes, I wouldn't dare to put this change into the 1.2 branch.. :-)
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
blog.brockha.us wrote:I thought about this, too. But then I though it is more typo save and more easy to use 3 bool values with meaningfull names and description, as most IDEs should give the signature description - my IDE eclipse does at least.
Yeah, that's true. My main concern is, that the paramter list of that function is already more than a foot long. *g*
If the parameter is just an array, where coders can put in anything, it doesn't look that stable to me.. What do you think? Perhaps another alternative, that didn't come into my mind?

We would be ubercool and define constants:

ENTRY_JOIN_CATEGORY
ENTRY_JOIN_AUTHORS
ENTRY_JOIN_ENTRYCAT

and use

serendipity_fetchEntries(..., ENTRY_JOIN_CATEGORY & ENTRY_JOIN_AUTHORS)

with bit-shifting. But I hate that mess. So maybe your way with seperate joins is better.

I'd combine 'category + entrycat' though. It doesn't make sense to join one, but not the other.

Best regards,
GArvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Post by blog.brockha.us »

garvinhicking wrote: I'd combine 'category + entrycat' though. It doesn't make sense to join one, but not the other.
Yes, you are right. Seperating them makes no sense at all. So we are in the middle: I had 3 parameters, you wanted 1 and now we will have two. :-)

Later: I changed this, retested it with multicategory articles (working!) and commited it into the SVN for s9y version 1.3.
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
Post Reply