Skip to content

Commit

Permalink
chore(backend): start refactoring for calendar event to contain corre…
Browse files Browse the repository at this point in the history
…ct type
  • Loading branch information
IgnisDa committed Aug 16, 2024
1 parent fc37cfe commit cb6f0e3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/models/database/src/calendar_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub timestamp: DateTimeUtc,
pub timestamp: DateTime,
pub date: NaiveDate,
pub metadata_id: Option<String>,
pub metadata_show_extra_information: Option<SeenShowExtraInformation>,
Expand Down
4 changes: 2 additions & 2 deletions crates/models/media/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{collections::HashSet, fmt, sync::Arc};

use async_graphql::{Enum, InputObject, InputType, OneofObject, SimpleObject, Union};
use boilermates::boilermates;
use chrono::{DateTime, NaiveDate};
use chrono::{DateTime, NaiveDate,NaiveDateTime};
use common_models::{
CollectionExtraInformation, IdAndNamedObject, SearchInput, StoredUrl, StringIdObject,
};
Expand Down Expand Up @@ -326,7 +326,7 @@ pub struct VisualNovelSpecifics {
#[graphql(input_name = "AnimeAiringScheduleSpecificsInput")]
pub struct AnimeAiringScheduleSpecifics {
pub episode: i32,
pub airing_at: DateTimeUtc,
pub airing_at: NaiveDateTime,
}

#[derive(
Expand Down
2 changes: 1 addition & 1 deletion crates/providers/src/anilist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ async fn media_details(
DateTimeUtc::from_timestamp(data.airing_at, 0).map(|airing_at| {
AnimeAiringScheduleSpecifics {
episode: data.episode.try_into().unwrap(),
airing_at,
airing_at: airing_at.naive_utc(),
}
})
})
Expand Down
11 changes: 6 additions & 5 deletions crates/services/miscellaneous/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use common_models::{
UserSummaryData,
};
use common_utils::{
convert_naive_to_utc, get_first_and_last_day_of_month, IsFeatureEnabled, AUTHOR,
SHOW_SPECIAL_SEASON_NAMES, TEMP_DIR, VERSION,
get_first_and_last_day_of_month, IsFeatureEnabled, AUTHOR, SHOW_SPECIAL_SEASON_NAMES, TEMP_DIR,
VERSION,
};
use database_models::{
calendar_event, collection, collection_to_entity,
Expand Down Expand Up @@ -5450,7 +5450,8 @@ impl MiscellaneousService {
if let Some(ps) = &meta.podcast_specifics {
for episode in ps.episodes.iter() {
let mut event = calendar_event_template.clone();
event.timestamp = ActiveValue::Set(convert_naive_to_utc(episode.publish_date));
event.timestamp =
ActiveValue::Set(episode.publish_date.and_hms_opt(0, 0, 0).unwrap());
event.metadata_podcast_extra_information =
ActiveValue::Set(Some(SeenPodcastExtraInformation {
episode: episode.number,
Expand All @@ -5465,7 +5466,7 @@ impl MiscellaneousService {
for episode in season.episodes.iter() {
if let Some(date) = episode.publish_date {
let mut event = calendar_event_template.clone();
event.timestamp = ActiveValue::Set(convert_naive_to_utc(date));
event.timestamp = ActiveValue::Set(date.and_hms_opt(0, 0, 0).unwrap());
event.metadata_show_extra_information =
ActiveValue::Set(Some(SeenShowExtraInformation {
season: season.season_number,
Expand All @@ -5490,7 +5491,7 @@ impl MiscellaneousService {
}
} else if let Some(publish_date) = meta.publish_date {
let mut event = calendar_event_template.clone();
event.timestamp = ActiveValue::Set(convert_naive_to_utc(publish_date));
event.timestamp = ActiveValue::Set(publish_date.and_hms_opt(0, 0, 0).unwrap());
calendar_events_inserts.push(event);
};
metadata_updates.push(meta.id.clone());
Expand Down

0 comments on commit cb6f0e3

Please sign in to comment.