Allow decimal numbers in Episodes tab
Amrayu78
Max Romanchenko task for you when you get the chance.
Max Romanchenko
Amrayu78 Done. You can now use decimals like 6.5. Please test.
Amrayu78
Max Romanchenko Tested this, but there's a logic error.
I'm guessing the number 7 is counting how many Episodes were added to the tab?
Max Romanchenko
Amrayu78 Yes, exactly.It's logical, isn't it? Even if you call the episode "6.5" (just a field), it's still a new entry. We've never had such special episodes as far as I can remember. Could you please clarify if anything else is needed? Because I'm a little confused. Is the problem with 6.5 solved?
Amrayu78
Max Romanchenko I think the logical thing is to copy the number (highest one) to the PB counter.
So it should say 6.5 of ??
It shouldn't say 7 of ??
The decimal is working as expected though.
Max Romanchenko
Amrayu78 Thanks for the explanation, just want to make sure I understand correctly what you're asking for.
Right now the code shows: count of added episodes of total episodes
So if you have episodes 1, 2, 3, 4, 5, 6, 6.5 added it shows "7 of ??"
You want it to show: highest episode number of total episodes
So same situation - it would show "6.5 of ??"
I need to point out a potential issue with this approach:
What if a title has episodes 1 and 5 added, but episodes 2, 3, 4 are missing?
Current logic: shows "2 of 10" - (correct - 2 episodes added)
Your proposed logic: shows "5 of 10" - (misleading - looks like 5 episodes are available, but only 2 actually exist)
This gets confusing for users, no?
Also, to implement this properly I'd need to:
Query all episodes for each title, find the highest episode number, store it somewhere (probably as post meta) to avoid performance issues.
This is fine for single pages, but in loops (archives, search...) it could become slow if we're querying episodes for every title.
So before I go ahead - is this really critical? The current logic has been working for a while without complaints. If you really need this, I can figure something out (probably with a migration to cache the highest episode number), but wanted to confirm first.
What do you think?
Amrayu78
Max Romanchenko
So if you have episodes 1, 2, 3, 4, 5, 6, 6.5 added it shows "7 of ??"
You want it to show: highest episode number of total episodes
So same situation - it would show "6.5 of ??" <-- Correct
----
I need to point out a potential issue with this approach:
What if a title has episodes 1 and 5 added, but episodes 2, 3, 4 are missing? <-- this will never happen/doesn't happen since we add/upload every single episode and not random ones. All episodes are added in order, one-by-one.
----
Current logic: shows "2 of 10" - (correct - 2 episodes added)
Your proposed logic: shows "5 of 10" - (misleading - looks like 5 episodes are available, but only 2 actually exist) <--- users associate the number with the total number of episodes available not the total number of files, 6.5 isn't actually counted.
----
I think there's probably an easier way.
This 6.5 episode shouldn't really be counted and isn't reflected in the total number of episodes, which is why it's labeled as 6.5. It's not an essential watch.
Since it shouldn't be counted, can we instead add a checkbox for such episodes to not be counted in the total?
What I'm worried about is after a series is done... it will show this:
11 of 10 <-- this I think will be more confusing to users if the number doesn't say 10 of 10. Again, users think of this number as the total number of episodes available and not the total number of files.
Let me know what you think.
Max Romanchenko
Amrayu78 okay, that makes more sense now. I see your point about the "11 of 10" situation - yeah, that would look weird.
The checkbox approach sounds reasonable. So basically:
Add a checkbox in the episode form like "Exclude from count" or "Special episode" (Please specify how best to name the field.)
This way at the end it'll correctly show "10 of 10" even if there are special episodes.
I think this is doable without major performance issues since we're still just counting, just with an extra condition. Let me implement this and I'll send you a update to test.
Amrayu78
Max Romanchenko Exclude from count works.
Max Romanchenko
Amrayu78 Done! I've added the new logic for recalculating episode counts based on the "Exclude from count" checkbox. It works in both admin and frontend, and handles all cases: creating, editing, and deleting episodes.
Updated templates:
- Episodes Tab
- Episode Delete Handler
- Relationships Handler
- Advanced Search Page
- Pirates Booty Page
- Treasure Island Page
- Drama/Movie/Special Template
- Archive Loop Template
- Seasons Homepage
The system now only creates the do_related_episodes_count (new field) when there are excluded episodes, so no migration is needed for existing titles. Please check it.