Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort news/push notifications #3164

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

PeterNerlich
Copy link
Collaborator

Short description

News items are sent out as push notifications to subscribed devices as well as served via our API. Push notifications are saved as separate objects in our database in order to retain the information for which news items we already sent notifications and to keep that separate from the concept of the content of the news item itself.

News items have a property last_updated, which describes when the content was last edited. Push Notification objects have a sent_date, which describes when the notification for this news item in that channel and this language was sent out. In the API, we only expose last_updated, which is the value also being displayed in the app. This can cause confusion whenever the date the news item was last edited is far before the date when it was actually sent.

Proposed changes

  • Add a value display_date to each news item returned by the API which equals either last_updated or sent_date of the corresponding push notification, whichever is greater (effectively clamping the value of last_updated to be no earlier than sent_date)
  • Sort the news entries returned by the API by the display_date value instead of last_updated

Alternatively, we could decide to alter last_updated or timestamp to the new behaviour. It seems that we deprecated timestamp in 2022 in favour of the new last_updated, but it is still in use by the app. There are hints that converting the timestamp to be in the local time zone of the server is the reason, but we should ask directly if we wish to pursue such an alternative.

Side effects

  • After this PR is merged and released, the app will need to switch from last_updated timestamp over to display_date. No further change should be required.
    If it aligns with how the app team handles this, Local news list sorting integreat-app#2952 might be repurposed for that request.

Resolved issues

Fixes: #2994


Pull Request Review Guidelines

@PeterNerlich PeterNerlich added the effort: low Should be doable in <4h label Oct 31, 2024
Copy link

codeclimate bot commented Oct 31, 2024

Code Climate has analyzed commit afd2f3a and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 82.4% (0.0% change).

View more on Code Climate.

Copy link
Member

@MizukiTemma MizukiTemma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 😸

@MizukiTemma
Copy link
Member

After this PR is merged and released, the app will need to switch from last_updated timestamp over to display_date. No further change should be required.
If it aligns with how the app team handles this, digitalfabrik/integreat-app#2952 might be repurposed for that request.

@steffenkleinle FYI

@steffenkleinle
Copy link
Member

steffenkleinle commented Nov 4, 2024

After this PR is merged and released, the app will need to switch from last_updated timestamp over to display_date. No further change should be required.
If it aligns with how the app team handles this, digitalfabrik/integreat-app#2952 might be repurposed for that request.

@steffenkleinle FYI

Thanks for the ping. Could we perhaps adjust the naming to last_update to be consistent with all other endpoints? In the end, sending a push notification is also some sort of update to the news item. Otherwise, this looks good as is.

I assume that the API will stay backwards compatible and keeps delivering the timestamp property?

I think the information that there is a last_updated property for news as well was just missed by us. Therefore it would be cool if we could just use that now (including the new functionality/logic).

Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a review, but I noticed that this change should be documented in our api documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: low Should be doable in <4h
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing order of push notifications in Integreat App/Website
4 participants