Upload databases.py
Browse files- databases.py +13 -5
databases.py
CHANGED
|
@@ -352,7 +352,7 @@ def get_audiodescription_history(sha1sum: str, version: str) -> list[sqlite3.Row
|
|
| 352 |
try:
|
| 353 |
sql = (
|
| 354 |
"SELECT * FROM audiodescriptions "
|
| 355 |
-
"WHERE sha1sum = ? AND version = ?
|
| 356 |
"ORDER BY COALESCE(updated_at, created_at, '') DESC, rowid DESC "
|
| 357 |
"LIMIT 1"
|
| 358 |
)
|
|
@@ -383,7 +383,7 @@ def get_audiodescription_history(sha1sum: str, version: str) -> list[sqlite3.Row
|
|
| 383 |
f"SELECT COUNT(*) FROM audiodescriptions WHERE sha1sum='{sha_pair}' AND version='{ver_pair}'"
|
| 384 |
).fetchone()[0]
|
| 385 |
count_nocase = conn_check.execute(
|
| 386 |
-
"SELECT COUNT(*) FROM audiodescriptions WHERE sha1sum=? AND version=?
|
| 387 |
(sha_pair, ver_pair),
|
| 388 |
).fetchone()[0]
|
| 389 |
print(
|
|
@@ -407,9 +407,17 @@ def get_audiodescription_history(sha1sum: str, version: str) -> list[sqlite3.Row
|
|
| 407 |
|
| 408 |
# Consulta principal per a sha1sum+versi贸 (nom茅s l'煤ltim registre)
|
| 409 |
cur = conn.execute(sql, (sha1sum, version))
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
if rows:
|
| 414 |
try:
|
| 415 |
print(
|
|
|
|
| 352 |
try:
|
| 353 |
sql = (
|
| 354 |
"SELECT * FROM audiodescriptions "
|
| 355 |
+
"WHERE sha1sum = ? AND LOWER(version) = LOWER(?) "
|
| 356 |
"ORDER BY COALESCE(updated_at, created_at, '') DESC, rowid DESC "
|
| 357 |
"LIMIT 1"
|
| 358 |
)
|
|
|
|
| 383 |
f"SELECT COUNT(*) FROM audiodescriptions WHERE sha1sum='{sha_pair}' AND version='{ver_pair}'"
|
| 384 |
).fetchone()[0]
|
| 385 |
count_nocase = conn_check.execute(
|
| 386 |
+
"SELECT COUNT(*) FROM audiodescriptions WHERE sha1sum=? AND LOWER(version)=LOWER(?)",
|
| 387 |
(sha_pair, ver_pair),
|
| 388 |
).fetchone()[0]
|
| 389 |
print(
|
|
|
|
| 407 |
|
| 408 |
# Consulta principal per a sha1sum+versi贸 (nom茅s l'煤ltim registre)
|
| 409 |
cur = conn.execute(sql, (sha1sum, version))
|
| 410 |
+
fetched_rows = cur.fetchall()
|
| 411 |
+
print(f"[DEBUG] get_audiodescription_history fetched {len(fetched_rows)} row(s) before slicing")
|
| 412 |
+
for idx, fetched in enumerate(fetched_rows):
|
| 413 |
+
try:
|
| 414 |
+
row_data = {key: fetched[key] for key in fetched.keys()}
|
| 415 |
+
print(f"[DEBUG] Row {idx}: {row_data}")
|
| 416 |
+
except Exception:
|
| 417 |
+
print(f"[DEBUG] Row {idx}: <unprintable> {type(fetched)}")
|
| 418 |
+
|
| 419 |
+
rows = fetched_rows[:1]
|
| 420 |
+
print(f"[DEBUG] get_audiodescription_history returning {len(rows)} row(s)")
|
| 421 |
if rows:
|
| 422 |
try:
|
| 423 |
print(
|