Currently Online

Latest Posts

Topic: Why are less "Most recently posted" shown than it used to?

hjd

Topic Opener
Joined: 2011-06-12, 20:24
Posts: 158
Ranking
At home in WL-forums
Location: bugs.launchpad.net/widelands
Posted at: 2011-09-03, 11:17

I have noticed some changes in the "Most recently posted"-section on the right side of the page. Most of them are improvements, such as showing how long it is since something was posted, rather than a date/timestamp. It also looks like if more than one comment is posted in the same thread, only the newest is listed, which I really like since it means more threads are shown instead of the same one over and over. However, it looks like at the same time, the number of entries has decreased from five to three. Was this intentional, or is this a side-effect of grouping the newest posts in the same thread?


Ships!

Top Quote
aber

Joined: 2010-04-18, 18:45
Posts: 52
Ranking
Likes to be here
Posted at: 2011-09-03, 13:11

This is mostly a side effect from the current implementation. The new code picks the last 5 different posts out of the last 25 posts.
This might need some tweaking. The current code is here: /pybb/templatetags/pybb_extras.py


Top Quote
Venatrix
Avatar
Joined: 2010-10-05, 20:31
Posts: 447
Ranking
Tribe Member
Location: Germany
Posted at: 2011-09-03, 14:27

hjd wrote:

However, it looks like at the same time, the number of entries has decreased from five to three.

I don’t know, what you mean. I see three entries (at least now). But do I understand right, that it may be, if there are just three different threads used in the last 25 posts, that effect can occur?

Edited: 2011-09-03, 14:28

Two is the oddest prime.

Top Quote
hjd

Topic Opener
Joined: 2011-06-12, 20:24
Posts: 158
Ranking
At home in WL-forums
Location: bugs.launchpad.net/widelands
Posted at: 2011-09-03, 15:03

Venatrix: Yes.

The old behavior was to just display whatever five latest posts had been posted. The thing is, if they are all from the same thread, it's just repetitious and redundant information. So it was changed to only display the latest post if more than one were from the same thread, which would ideally allow us to display a wider selection of the various threads currently discussed. (Or at least I assume this was the reason. I wasn't really involved when the change took place, but I do like it.)

The easiest fix would be to increase the number of latest posts looked at when filtering based on threads. This has the drawback of possible breaking at some point if a single thread gets more than X replies in a short time and no other threads are posted to. Alternatively the query could be improved so that it only fetches posts from different threads. This would be fairly easy to do in sql, but I am not sure how it is handled (or how easy it would be) through what looks like an ORM-thingy in the code.


Ships!

Top Quote
SirVer

Joined: 2009-02-19, 15:18
Posts: 1440
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2011-09-05, 12:09

I'll glady merge any patch provided face-tongue.png


Top Quote
aber

Joined: 2010-04-18, 18:45
Posts: 52
Ranking
Likes to be here
Posted at: 2011-09-05, 18:20

Uhh ohh, what do you think about:
trunk/revision/269
Sorry for the way to present this... This was more like an accident to push to trunk...


Top Quote
hjd

Topic Opener
Joined: 2011-06-12, 20:24
Posts: 158
Ranking
At home in WL-forums
Location: bugs.launchpad.net/widelands
Posted at: 2011-09-05, 21:24

I'm not really familiar with how the database is organized, but the query looks nice. And somewhat neater than I imagined.


Ships!

Top Quote
aber

Joined: 2010-04-18, 18:45
Posts: 52
Ranking
Likes to be here
Posted at: 2011-09-12, 18:32

so, you imagined it would be more complicated. I tell you something it is not working in postgres (for more or less good reasens).

CREATE TABLE "pybb_post" (
    "id" serial NOT NULL PRIMARY KEY,
    "topic_id" integer NOT NULL REFERENCES "pybb_topic" ("id") DEFERRABLE INITIALLY DEFERRED,
    "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
    "created" timestamp with time zone NOT NULL,
    "updated" timestamp with time zone,
    "markup" varchar(15) NOT NULL,
    "body" text NOT NULL,
    "body_html" text NOT NULL,
    "body_text" text NOT NULL,
    "user_ip" inet NOT NULL
)


SELECT id FROM (SELECT topic_id, MAX(created) AS created FROM pybb_post GROUP BY topic_id LIMIT 5) AS last JOIN pybb_post ON last.created = pybb_post.created AND last.topic_id = pybb_post.topic_id ORDER BY last.created DESC;'


This is my idea, but the output is not correct in all cases. The second idea would be to do massive amount of cheating an use this statement. So, what do you guys think? Help!

SELECT MAX(id) AS id FROM pybb_post GROUP BY topic_id ORDER BY id DESC LIMIT 5;

Top Quote