mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Ensure stable sort when no lang is specified
This commit is contained in:
parent
985a13c1e4
commit
26410734fc
@ -271,6 +271,8 @@ export async function getShows({
|
|||||||
.orderBy(
|
.orderBy(
|
||||||
showTranslations.pk,
|
showTranslations.pk,
|
||||||
sql`array_position(${sqlarr(languages)}, ${showTranslations.language})`,
|
sql`array_position(${sqlarr(languages)}, ${showTranslations.language})`,
|
||||||
|
// ensure a stable sort to prevent future pages to contains the same element again
|
||||||
|
showTranslations.language,
|
||||||
)
|
)
|
||||||
.as("t");
|
.as("t");
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
type TSchema,
|
type TSchema,
|
||||||
type TString,
|
type TString,
|
||||||
} from "@sinclair/typebox";
|
} from "@sinclair/typebox";
|
||||||
import { type Column, type Table, eq, sql } from "drizzle-orm";
|
import { type Column, eq, sql, type Table } from "drizzle-orm";
|
||||||
import { t } from "elysia";
|
import { t } from "elysia";
|
||||||
import { sqlarr } from "~/db/utils";
|
import { sqlarr } from "~/db/utils";
|
||||||
import { comment } from "../../utils";
|
import { comment } from "../../utils";
|
||||||
@ -74,7 +74,7 @@ export const TranslationRecord = <T extends TSchema>(
|
|||||||
.Encode((x) => x);
|
.Encode((x) => x);
|
||||||
|
|
||||||
export const processLanguages = (languages?: string) => {
|
export const processLanguages = (languages?: string) => {
|
||||||
if (!languages) return ["*"];
|
if (!languages) return ["en", "*"];
|
||||||
return languages
|
return languages
|
||||||
.split(",")
|
.split(",")
|
||||||
.map((x) => {
|
.map((x) => {
|
||||||
@ -91,9 +91,11 @@ export const processLanguages = (languages?: string) => {
|
|||||||
|
|
||||||
export const AcceptLanguage = ({
|
export const AcceptLanguage = ({
|
||||||
autoFallback = false,
|
autoFallback = false,
|
||||||
}: { autoFallback?: boolean } = {}) =>
|
}: {
|
||||||
|
autoFallback?: boolean;
|
||||||
|
} = {}) =>
|
||||||
t.String({
|
t.String({
|
||||||
default: "*",
|
default: "en, *",
|
||||||
example: "en-us, ja;q=0.5",
|
example: "en-us, ja;q=0.5",
|
||||||
description:
|
description:
|
||||||
comment`
|
comment`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user