Parse a YYYY-MM-DD release date into a sortable tuple. Missing or malformed dates (\\N, empty, non-ISO) collapse to (0, 0, 0) so they always lose ranking comparisons against real dates.
(s: str)
| 429 | |
| 430 | |
| 431 | def _parse_date(s: str) -> tuple[int, int, int]: |
| 432 | """Parse a YYYY-MM-DD release date into a sortable tuple. |
| 433 | |
| 434 | Missing or malformed dates (\\N, empty, non-ISO) collapse to (0, 0, 0) |
| 435 | so they always lose ranking comparisons against real dates. |
| 436 | """ |
| 437 | if not s or s == "\\N": |
| 438 | return (0, 0, 0) |
| 439 | try: |
| 440 | y, m, d = s.split("-") |
| 441 | return (int(y), int(m), int(d)) |
| 442 | except ValueError: |
| 443 | return (0, 0, 0) |
| 444 | |
| 445 | |
| 446 | def select_content_ids( |