Skip to content

Commit

Permalink
feat(backend): fixing specials
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Jun 21, 2024
1 parent 2cec0a6 commit 9fa440b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
17 changes: 10 additions & 7 deletions apps/backend/src/miscellaneous/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ use crate::{
utils::{
add_entity_to_collection, associate_user_with_entity, entity_in_collections,
get_current_date, get_stored_asset, get_user_to_entity_association, ilike_sql,
partial_user_by_id, user_by_id, user_id_from_token, AUTHOR, SHOW_SPECIALS_SEASON_NAME,
partial_user_by_id, user_by_id, user_id_from_token, AUTHOR, SHOW_SPECIAL_SEASON_NAMES,
TEMP_DIR,
},
};
Expand Down Expand Up @@ -5833,7 +5833,7 @@ impl MiscellaneousService {
let all_episodes = if let Some(s) = metadata.model.show_specifics {
s.seasons
.into_iter()
.filter(|s| s.name != SHOW_SPECIALS_SEASON_NAME)
.filter(|s| !SHOW_SPECIAL_SEASON_NAMES.contains(&s.name.as_str()))
.flat_map(|s| {
s.episodes
.into_iter()
Expand Down Expand Up @@ -6623,10 +6623,13 @@ impl MiscellaneousService {
let mut need_to_delete = true;
if let Some(show) = cal_event.metadata_show_extra_information {
if let Some(show_info) = &meta.show_specifics {
if let Some((_, ep)) = show_info.get_episode(show.season, show.episode) {
if let Some(publish_date) = ep.publish_date {
if publish_date == cal_event.date {
need_to_delete = false;
if let Some((season, ep)) = show_info.get_episode(show.season, show.episode)
{
if !SHOW_SPECIAL_SEASON_NAMES.contains(&season.name.as_str()) {
if let Some(publish_date) = ep.publish_date {
if publish_date == cal_event.date {
need_to_delete = false;
}
}
}
}
Expand Down Expand Up @@ -6687,7 +6690,7 @@ impl MiscellaneousService {
}
} else if let Some(ss) = &meta.show_specifics {
for season in ss.seasons.iter() {
if season.name == SHOW_SPECIALS_SEASON_NAME {
if SHOW_SPECIAL_SEASON_NAMES.contains(&season.name.as_str()) {
continue;
}
for episode in season.episodes.iter() {
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/providers/tmdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::{
IdObject, NamedObject, SearchDetails, SearchResults, StoredUrl,
},
traits::{MediaProvider, MediaProviderLanguages},
utils::{get_base_http_client, get_current_date, SHOW_SPECIALS_SEASON_NAME, TEMP_DIR},
utils::{get_base_http_client, get_current_date, SHOW_SPECIAL_SEASON_NAMES, TEMP_DIR},
};

static URL: &str = "https://api.themoviedb.org/3/";
Expand Down Expand Up @@ -1119,7 +1119,7 @@ impl MediaProvider for TmdbShowService {
.sum();
let seasons_without_specials = seasons
.iter()
.filter(|s| s.name != SHOW_SPECIALS_SEASON_NAME)
.filter(|s| !SHOW_SPECIAL_SEASON_NAMES.contains(&s.name.as_str()))
.collect_vec();
let total_seasons = seasons_without_specials.len();
let total_episodes = seasons_without_specials
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub const USER_AGENT_STR: &str = const_str::concat!(
pub const AVATAR_URL: &str =
"https://raw.githubusercontent.com/IgnisDa/ryot/main/libs/assets/icon-512x512.png";
pub const TEMP_DIR: &str = "tmp";
pub const SHOW_SPECIALS_SEASON_NAME: &str = "Specials";
pub const SHOW_SPECIAL_SEASON_NAMES: [&str; 2] = ["Specials", "Extras"];
pub static JSON: HeaderValue = HeaderValue::from_static("application/json");

const FRONTEND_OAUTH_ENDPOINT: &str = "/api/auth";
Expand Down
11 changes: 4 additions & 7 deletions apps/frontend/app/routes/_dashboard.media.item.$id._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,13 @@ const showSpecificsSchema = z.array(

const podcastSpecificsSchema = z.array(z.object({ episodeNumber: z.number() }));

// DEV: I wanted to use fetcher in some place but since this is being rendered
// conditionally (or inside a menu), the form ref is null.

export default function Page() {
const loaderData = useLoaderData<typeof loader>();
const getMantineColor = useGetMantineColor();

const [tab, setTab] = useState<string | null>(
loaderData.query.defaultTab || "overview",
);
const [
progressModalOpened,
{ open: progressModalOpen, close: progressModalClose },
Expand Down Expand Up @@ -738,10 +738,7 @@ export default function Page() {
</>
)}
</UserMetadataDetailsSuspenseLoader>
<Tabs
variant="outline"
defaultValue={loaderData.query.defaultTab || "overview"}
>
<Tabs variant="outline" value={tab} onChange={(t) => setTab(t)}>
<Tabs.List mb="xs">
<Tabs.Tab
value="overview"
Expand Down

0 comments on commit 9fa440b

Please sign in to comment.