Merge remote-tracking branch 'upstream/main' into dev
This commit is contained in:
commit
6b29556ef8
836 changed files with 1598388 additions and 64684 deletions
|
|
@ -1,10 +0,0 @@
|
|||
-- name: GetAuthKey :one
|
||||
SELECT auth_key_id, body, server_salt, created_at
|
||||
FROM auth_keys
|
||||
WHERE auth_key_id = $1;
|
||||
|
||||
-- name: UpsertAuthKey :exec
|
||||
INSERT INTO auth_keys (auth_key_id, body, server_salt)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (auth_key_id) DO UPDATE
|
||||
SET body = EXCLUDED.body, server_salt = EXCLUDED.server_salt;
|
||||
|
|
@ -30,6 +30,36 @@ ON CONFLICT (lang_pack, lang_code, key) DO UPDATE SET
|
|||
deleted = EXCLUDED.deleted,
|
||||
updated_at = now();
|
||||
|
||||
-- name: ListLangPackCodes :many
|
||||
SELECT lang_code
|
||||
FROM lang_packs
|
||||
WHERE lang_pack = $1
|
||||
ORDER BY lang_code;
|
||||
|
||||
-- name: DeleteLangPackStrings :exec
|
||||
DELETE FROM lang_pack_strings
|
||||
WHERE lang_pack = $1 AND lang_code = $2;
|
||||
|
||||
-- name: DeleteLangPackMeta :exec
|
||||
DELETE FROM lang_packs
|
||||
WHERE lang_pack = $1 AND lang_code = $2;
|
||||
|
||||
-- name: GetLangPackSeedHash :one
|
||||
SELECT content_hash
|
||||
FROM seed_states
|
||||
WHERE key = $1;
|
||||
|
||||
-- name: PutLangPackSeedHash :exec
|
||||
INSERT INTO seed_states (key, content_hash)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (key) DO UPDATE SET
|
||||
content_hash = EXCLUDED.content_hash,
|
||||
updated_at = now();
|
||||
|
||||
-- name: DeleteLangPackSeedHash :exec
|
||||
DELETE FROM seed_states
|
||||
WHERE key = $1;
|
||||
|
||||
-- name: ListLangPackStrings :many
|
||||
SELECT
|
||||
lang_pack, lang_code, key, version, pluralized, value,
|
||||
|
|
@ -45,3 +75,48 @@ SELECT
|
|||
FROM lang_pack_strings
|
||||
WHERE lang_pack = $1 AND lang_code = $2 AND key = ANY(sqlc.arg(keys)::text[]) AND NOT deleted
|
||||
ORDER BY key;
|
||||
|
||||
-- name: ListLangPackLanguages :many
|
||||
SELECT
|
||||
p.lang_pack,
|
||||
p.lang_code,
|
||||
p.version,
|
||||
p.strings_count,
|
||||
COALESCE(
|
||||
MAX(s.value) FILTER (WHERE s.key = 'LanguageNameInEnglish'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'Localization.EnglishLanguageName'),
|
||||
''
|
||||
)::text AS name,
|
||||
CASE
|
||||
WHEN p.lang_pack = 'android' THEN COALESCE(
|
||||
MAX(s.value) FILTER (WHERE s.key = 'TranslateLanguage' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'PassportLanguage_' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'LanguageName'),
|
||||
''
|
||||
)
|
||||
ELSE COALESCE(
|
||||
MAX(s.value) FILTER (WHERE s.key = 'lng_language_name'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'LanguageName'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'Localization.LanguageName'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'TranslateLanguage' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'PassportLanguage_' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
''
|
||||
)
|
||||
END::text AS native_name
|
||||
FROM lang_packs p
|
||||
LEFT JOIN lang_pack_strings s
|
||||
ON s.lang_pack = p.lang_pack
|
||||
AND s.lang_code = p.lang_code
|
||||
AND s.key = ANY(ARRAY[
|
||||
'lng_language_name',
|
||||
'LanguageName',
|
||||
'LanguageNameInEnglish',
|
||||
'Localization.LanguageName',
|
||||
'Localization.EnglishLanguageName',
|
||||
'TranslateLanguage' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1)),
|
||||
'PassportLanguage_' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))
|
||||
]::text[])
|
||||
AND NOT s.deleted
|
||||
WHERE p.lang_pack = $1
|
||||
GROUP BY p.lang_pack, p.lang_code, p.version, p.strings_count
|
||||
ORDER BY p.lang_code;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
-- name: UpsertTempAuthKeyBinding :exec
|
||||
-- name: UpsertTempAuthKeyBinding :execrows
|
||||
INSERT INTO temp_auth_key_bindings (
|
||||
temp_auth_key_id, perm_auth_key_id, nonce, temp_session_id, expires_at, encrypted_message
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
SELECT $1, $2, $3, $4, $5, $6
|
||||
FROM auth_keys AS temp_key
|
||||
JOIN auth_keys AS perm_key ON perm_key.auth_key_id = $2
|
||||
WHERE temp_key.auth_key_id = $1
|
||||
AND temp_key.expires_at = $5
|
||||
AND temp_key.expires_at > 0
|
||||
AND perm_key.expires_at = 0
|
||||
ON CONFLICT (temp_auth_key_id) DO UPDATE SET
|
||||
perm_auth_key_id = EXCLUDED.perm_auth_key_id,
|
||||
nonce = EXCLUDED.nonce,
|
||||
temp_session_id = EXCLUDED.temp_session_id,
|
||||
expires_at = EXCLUDED.expires_at,
|
||||
encrypted_message = EXCLUDED.encrypted_message,
|
||||
created_at = now();
|
||||
created_at = now()
|
||||
WHERE temp_auth_key_bindings.perm_auth_key_id = EXCLUDED.perm_auth_key_id;
|
||||
|
||||
-- name: GetTempAuthKeyBinding :one
|
||||
SELECT
|
||||
|
|
@ -23,10 +29,15 @@ FROM temp_auth_key_bindings
|
|||
WHERE temp_auth_key_id = $1;
|
||||
|
||||
-- name: DeleteExpiredTempAuthKeys :execrows
|
||||
DELETE FROM auth_keys
|
||||
WHERE auth_key_id IN (
|
||||
SELECT temp_auth_key_id
|
||||
FROM temp_auth_key_bindings
|
||||
WHERE expires_at < $1
|
||||
WITH candidates AS (
|
||||
SELECT candidate_key.auth_key_id
|
||||
FROM auth_keys AS candidate_key
|
||||
WHERE candidate_key.expires_at > 0
|
||||
AND candidate_key.expires_at < $1
|
||||
ORDER BY candidate_key.expires_at, candidate_key.auth_key_id
|
||||
LIMIT $2
|
||||
);
|
||||
FOR UPDATE SKIP LOCKED
|
||||
)
|
||||
DELETE FROM auth_keys AS k
|
||||
USING candidates AS c
|
||||
WHERE k.auth_key_id = c.auth_key_id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue