totaldebug / atomic-calendar-revive

An advanced calendar card for Home Assistant Lovelace.
https://docs.totaldebug.uk/atomic-calendar-revive
MIT License
391 stars 63 forks source link

Using maxEventCount with (only) all day events drops the wrong events #1338

Closed m-idler closed 5 months ago

m-idler commented 6 months ago

Is there an existing issue for this?

Current Behavior

I have a calendar that contains only fall day events of national holidays here in germany ( http://i.cal.to/ical/65/bayern/feiertage/ef570601.d382ba80-b11081be.ics ). As I only want to see the next e.g. 3 upcoming holidays, I'm using (maxDaysToShow: 180 and maxEventCount: 3). After debugging i little bit through the code, it seems the the already correctly sorted events are mixed up and finally the wrong events get dropped...

Current Output (with maxEventCount: 3): Screenshot 2023-12-28 at 23 01 24

Current Output (without maxEventCount): Screenshot 2023-12-28 at 23 03 10

Expected behaviour

I would expect that the events will be limited according the expected sort order

Steps To Reproduce

Sorting in https://github.com/totaldebug/atomic-calendar-revive/blob/5b70a35bc170906c0d6eb572d263b129fde80152/src/functions/sort_events.ts#L33 is done as expected (as of today it's 8 events in the correct order based on event start

afterwards the all day events get into reverse order in https://github.com/totaldebug/atomic-calendar-revive/blob/5b70a35bc170906c0d6eb572d263b129fde80152/src/functions/sort_events.ts#L42 due to the decrementing loop

and then the all day events get reordered here, now they aren't ordered by start time anymore: https://github.com/totaldebug/atomic-calendar-revive/blob/5b70a35bc170906c0d6eb572d263b129fde80152/src/functions/sort_events.ts#L48 (as I'm not to deep in all the details of the code and especially this all day event sorting, I'm not sure whether there is also a typo in https://github.com/totaldebug/atomic-calendar-revive/blob/5b70a35bc170906c0d6eb572d263b129fde80152/src/functions/sort_events.ts#L50 , comparing entity_id with entity?

and finally those reordered all day events go back into the events list in that new order here: https://github.com/totaldebug/atomic-calendar-revive/blob/5b70a35bc170906c0d6eb572d263b129fde80152/src/functions/sort_events.ts#L63

Mode

Both

Card Version

9.2.1

Home Assistant Version

2023.12.4

Configuration

type: custom:atomic-calendar-revive
name: Feiertage
enableModeChange: true
entities:
  - entity: calendar.feiertage
    showMultiDay: true
    maxDaysToShow: 180
disableCalLink: true
disableCalLocationLink: true
disableCalEventLink: true
showDescription: false
showWeekDay: true
showMonth: true
disableEventLink: true
showCalendarName: true
maxDaysToShow: 180
maxEventCount: 3
showLocation: false
showRelativeTime: false
europeanDate: true
showHiddenText: false
showAllDayHours: false
offsetHeaderDate: false
showProgressBar: false
dimFinishedEvents: true

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 6 months ago

Hello @m-idler, thank you for your interest in our work! If this is a bug report, please provide your configuration and any screenshots that would assist troubleshooting, otherwise we can not help you.

h3rbst commented 5 months ago

I have this problem as well. Any workaround?

Pscharumbel commented 5 months ago

Same. Still with 9.3.0.

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 9.3.0-beta.3 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

marksie1988 commented 5 months ago

This should now be resolved on the latest Beta, Please test and let me know how it works out then I will release.

Pscharumbel commented 5 months ago

Hi!

Thanks for your work! Unfortunately, the error persists despite the beta, as soon as I remove maxDaysToShow.

h3rbst commented 5 months ago

For me it is not working with Beta 3 as well :(

marksie1988 commented 5 months ago

@h3rbst what are you seeing that is incorrect?

Have you made sure the old version of the card is still not cached?

marksie1988 commented 5 months ago

Hi!

Thanks for your work! Unfortunately, the error persists despite the beta, as soon as I remove maxDaysToShow.

What are you seeing that is incorrect as I cant replicate an issue with all day events being in the wrong order anymore?

Do you have a copy of your card config that could assist me in testing?

h3rbst commented 5 months ago

@h3rbst what are you seeing that is incorrect?

Have you made sure the old version of the card is still not cached?

I am sure, that cache is cleared, yes. Here you see the configuration, how it looks like and what the calendar looks like. E.g. the dates of 25.03. and 28.03. are missing. With maxDaysToShow: 14 they are shown.

Bildschirmfoto 2024-01-15 um 14 42 04 Bildschirmfoto 2024-01-15 um 14 43 27 Bildschirmfoto 2024-01-15 um 14 44 00
marksie1988 commented 5 months ago

@h3rbst ok and those events are from a different calendar?

h3rbst commented 5 months ago

@marksie1988 exactly "Restmüll" is from the first one The date on 28.03. is from the second one The orange ones are the last one (in the config)

marksie1988 commented 5 months ago

Ok thanks ill look into that, I only tested across one of my calendars so will test with two now

Pscharumbel commented 5 months ago

Yes, I also have multiple calendars. 😃

marksie1988 commented 5 months ago

I have done more testing this morning and im unable to reproduce an issue with the sorting since adding the fix:

image

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 9.4.0-beta.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 9.4.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: