Posts in agenda are not sorted anymore

Posts in agenda are not sorted anymore
0

Environment

Discourse Version: 2.4.0

Plugin Commit: 3bb595c (but the bug has occurred for at least 1 month)

Other Plugins

  • discourse-checklist 0.4.1 O
  • discourse-custom-wizard 0.1 O
  • discourse-data-explorer 0.2 O
  • discourse-events 0.1 O
  • discourse-footnote 0.1 O
  • discourse-locations 0.1 O
  • discourse-math 0.9 N
  • discourse-quick-messages 0.1 N
  • discourse-sidebar-categories 0.1 O
  • discourse-solved 0.1 O
  • discourse-whos-online 1.0 O
  • docker_manager

The bugs still occurs on a vanilla theme.

Steps to Reproduce

I can’t explain how the bug had happened, it is just here.
I host other forums with similar settings and it had not happened.

I’m asking for directions about what could have provoked it so I can test and fix my settings rather than asking you to correct anything in the codebase.

Example

https:// forum {dot} cm-en-transition {dot} fr/agenda

Feel free to create an account. If you name it test-<something>, i’ll able to delete it afterwards.

Logs

I have no idea which one would be useful. Actually, I’m looking for a hint to debug it myself but I don’t know where to start.

1 Like

@angus, do we actually sort url.com/agenda ?

@fzngagan It’s meant to be sorted by time (ascending)

1 Like

I have the same Problem…

Installed Plugins:

  • babble 4.1.1
  • discourse-calendar 0.2
  • discourse-data-explorer 0.2
  • discourse-events 0.1
  • discourse-locations 0.1
  • discourse-multilingual-support 0.5
  • discourse-quick-messages 0.1
  • discourse-sitemap 1.2
  • discourse-solved 0.1
  • discourse-telegram-notifications 0.1
  • docker_manager 0.1
  • procourse-static-pages

2 Likes

Taking a look at this.

by time you mean event_start

@tobiaseigen do you have a clue about this one?

Hey sorry for not responding sooner. Missed this somehow…

I dont really use the agenda view. But I just enabled it and cannot replicate the issue. It sorts as expected. Maybe you could describe in more detail what you are expecting to see?

That said, it seems the agenda view could be improved, with a simpler list of calendar items in a list that can be sorted ascending or descending, or filtered in various ways.

1 Like

I can still reproduce on my instance, see my earlier post that documents this behavior:

It seems to sort by the Activity column, while Agenda view should sort by the date on the event. Perhaps you can try to reproduce by responding to some old event?

If there was a discourse playground with events plugin and agenda hamburger menu enabled, I wouldn’t mind trying to create a demo.

If you’re the site admin, you can see the profiler at the top left of your screen. If you can paste the query generated while fetching topics, That would make looking into this a lot easier.

1 Like
SELECT "topics".* FROM "topics" LEFT OUTER JOIN topic_users AS tu ON (topics.id = tu.topic_id AND tu.user_id = 1) INNER JOIN topic_custom_fields
                ON topic_custom_fields.topic_id = topics.id
                AND topic_custom_fields.name = 'event_start'
                AND topic_custom_fields.value <> '' WHERE (topics.archetype <> 'private_message') AND (NOT topics.closed AND NOT topics.archived) AND (topics.deleted_at IS NULL) ORDER BY topics.bumped_at ASC, (
          SELECT CASE
          WHEN EXISTS (
            SELECT true FROM topic_custom_fields tcf
            WHERE tcf.topic_id::integer = topics.id::integer
            AND tcf.name = 'event_start' LIMIT 1
          )
          THEN (
            SELECT value::integer FROM topic_custom_fields tcf
            WHERE tcf.topic_id::integer = topics.id::integer
            AND tcf.name = 'event_start' LIMIT 1
          )
          ELSE 0 END
        ) ASC LIMIT 30 OFFSET 30; 

Ah, here is the culprit ORDER BY topics.bumped_at ASC

Edit: the above was for agenda.json, here is the main one including call stack:

Summary
lib/topic_query.rb:427:in `create_list'
plugins/discourse-events/plugin.rb:411:in `list_agenda'
app/controllers/list_controller.rb:57:in `public_send'
app/controllers/list_controller.rb:57:in `block (2 levels) in '
lib/middleware/omniauth_bypass_middleware.rb:68:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:318:in `call'
config/initializers/100-quiet_logger.rb:18:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:17:in `call'
lib/middleware/request_tracker.rb:181:in `call'
SELECT "topics".* FROM "topics" LEFT OUTER JOIN topic_users AS tu ON (topics.id = tu.topic_id AND tu.user_id = 1) INNER JOIN topic_custom_fields
                ON topic_custom_fields.topic_id = topics.id
                AND topic_custom_fields.name = 'event_start'
                AND topic_custom_fields.value <> '' WHERE (topics.archetype <> 'private_message') AND (NOT topics.closed AND NOT topics.archived) AND (topics.deleted_at IS NULL) ORDER BY topics.bumped_at ASC, (
          SELECT CASE
          WHEN EXISTS (
            SELECT true FROM topic_custom_fields tcf
            WHERE tcf.topic_id::integer = topics.id::integer
            AND tcf.name = 'event_start' LIMIT 1
          )
          THEN (
            SELECT value::integer FROM topic_custom_fields tcf
            WHERE tcf.topic_id::integer = topics.id::integer
            AND tcf.name = 'event_start' LIMIT 1
          )
          ELSE 0 END
        ) ASC LIMIT 30; 
1 Like

Is it a dev setup?

No, it is production. I may not be able to help debug today or in the next two weeks because of pending deadlines.

I posted just to confirm that it is still an issue over all these months and I have been keeping the Agenda hamburger menu turned off as it shows incorrectly sorted events.

1 Like

Looking on desktop now, I can see that there are some issues and am able to replicate… take a look at https://community.namati.org/agenda?ascending=true&order=activity

Toggle the ACTIVITY column heading and nothing changes.

I initially had events remove past from agenda admin setting disabled, and the items appear to have been displayed in the correct order - but then it also included alot of old content with the newer stuff pushed down and needing to be autoloaded. Useless.

Now with events remove past from agenda enabled, the sort order is incorrect but cannot be changed. Only two items in the agenda - need to talk to my colleagues about adding event details. :wink:

Personally, I think the agenda view needs to be reworked and until it is, is best disabled.

1 Like