Posts in agenda are not sorted anymore

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.

1 Like

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.

2 Likes

Thanks for this report. I’m checking the cause of this side effect.

1 Like

The behaviour I am specing here is,

  1. If no sort order is being applied, sort by event dates(agenda logic).
  2. If a sort order is being applied, sort by the set order.
  3. The remove past events setting shouldn’t affect any of this.

Thoughts?

1 Like

Hey there - sorry for neglecting this. It’s great to see you’re working on the agenda view of the events plugin. Your plan looks good for the agenda view as it exists now so if it’s not too much effort to fix I would proceed as planned.

However if you’re putting in alot of work here I would prefer to see the agenda view improved to look more like a google calendar agenda view, which is a cleaner list integrated with the calendar. It’s what people have come to expect, methinks, to get a quick overview of all the events coming up without alot of discussion features to distract the user. A toggle could be provided at the top to hide/show past events.

Wow, my personal calendar is boring. But gives you an idea what I mean.

This screenshot from my forum shows how the same popups could be used to display event details.

A huge refactor is underway. Documentation too. I’ve included the fix there. Not sure you’re in a position to play with a test branch?

1 Like

I don’t have a dev instance but can test on my personal site if it’s reasonably alpha. :wink:

1 Like

It sure is. My dev instance boots up when I start it with my branch. Lol its better than that honestly :wink:

Its in a good position to be run on a test instance honestly. @md-misko is already doing that.

Here it is: Commits · paviliondev/discourse-events · GitHub

2 Likes