From df2fc57a6329bf4ca7403918897d18bbfc88caf9 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Thu, 27 Jul 2023 17:30:43 +0300 Subject: [PATCH] feat: NotificationBucket - add last_updated datetime Signed-off-by: Lachezar Lechev --- src/models/ctx/update_notifications.rs | 2 +- src/types/addon/response.rs | 1 - src/types/notifications/notifications_bucket.rs | 9 ++++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/models/ctx/update_notifications.rs b/src/models/ctx/update_notifications.rs index 64855e676..d488c5643 100644 --- a/src/models/ctx/update_notifications.rs +++ b/src/models/ctx/update_notifications.rs @@ -63,7 +63,7 @@ pub fn update_notifications( }, ); - notifications.created = E::now(); + notifications.last_updated = Some(E::now()); let notification_items_effects = update_notification_items::( &mut notifications.items, notification_catalogs, diff --git a/src/types/addon/response.rs b/src/types/addon/response.rs index c80699286..f764d6736 100644 --- a/src/types/addon/response.rs +++ b/src/types/addon/response.rs @@ -7,7 +7,6 @@ use crate::types::{ resource::{MetaItem, MetaItemPreview, Stream, Subtitles}, }; - /// Resource Response from an addon. /// /// Deserializing the struct from json will skip any invalid Vec items diff --git a/src/types/notifications/notifications_bucket.rs b/src/types/notifications/notifications_bucket.rs index e55f24549..2049109b3 100644 --- a/src/types/notifications/notifications_bucket.rs +++ b/src/types/notifications/notifications_bucket.rs @@ -15,9 +15,15 @@ use crate::{ #[derive(Default, Derivative, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub struct NotificationsBucket { + #[serde(default)] pub uid: UID, - /// Notifications + /// Notifications per meta item and video id + #[serde(default)] pub items: HashMap>, + /// The last time notifications were pulled. + #[serde(default)] + pub last_updated: Option>, + /// The moment that the notification bucket was initialized. #[derivative(Default(value = "Utc::now()"))] pub created: DateTime, } @@ -39,6 +45,7 @@ impl NotificationsBucket { acc }), + last_updated: None, created: E::now(), } }