Add ipfs_cid to all asset SELECT queries
The ipfs_cid column was being stored but not retrieved in queries, causing the UI to show "Not on IPFS" even when the data exists. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
10
db.py
10
db.py
@@ -185,7 +185,7 @@ async def get_asset(name: str) -> Optional[dict]:
|
|||||||
"""Get asset by name."""
|
"""Get asset by name."""
|
||||||
async with get_connection() as conn:
|
async with get_connection() as conn:
|
||||||
row = await conn.fetchrow(
|
row = await conn.fetchrow(
|
||||||
"""SELECT name, content_hash, asset_type, tags, metadata, url,
|
"""SELECT name, content_hash, ipfs_cid, asset_type, tags, metadata, url,
|
||||||
provenance, description, origin, owner, created_at, updated_at
|
provenance, description, origin, owner, created_at, updated_at
|
||||||
FROM assets WHERE name = $1""",
|
FROM assets WHERE name = $1""",
|
||||||
name
|
name
|
||||||
@@ -199,7 +199,7 @@ async def get_asset_by_hash(content_hash: str) -> Optional[dict]:
|
|||||||
"""Get asset by content hash."""
|
"""Get asset by content hash."""
|
||||||
async with get_connection() as conn:
|
async with get_connection() as conn:
|
||||||
row = await conn.fetchrow(
|
row = await conn.fetchrow(
|
||||||
"""SELECT name, content_hash, asset_type, tags, metadata, url,
|
"""SELECT name, content_hash, ipfs_cid, asset_type, tags, metadata, url,
|
||||||
provenance, description, origin, owner, created_at, updated_at
|
provenance, description, origin, owner, created_at, updated_at
|
||||||
FROM assets WHERE content_hash = $1""",
|
FROM assets WHERE content_hash = $1""",
|
||||||
content_hash
|
content_hash
|
||||||
@@ -213,7 +213,7 @@ async def get_all_assets() -> dict[str, dict]:
|
|||||||
"""Get all assets as a dict indexed by name."""
|
"""Get all assets as a dict indexed by name."""
|
||||||
async with get_connection() as conn:
|
async with get_connection() as conn:
|
||||||
rows = await conn.fetch(
|
rows = await conn.fetch(
|
||||||
"""SELECT name, content_hash, asset_type, tags, metadata, url,
|
"""SELECT name, content_hash, ipfs_cid, asset_type, tags, metadata, url,
|
||||||
provenance, description, origin, owner, created_at, updated_at
|
provenance, description, origin, owner, created_at, updated_at
|
||||||
FROM assets ORDER BY created_at DESC"""
|
FROM assets ORDER BY created_at DESC"""
|
||||||
)
|
)
|
||||||
@@ -225,7 +225,7 @@ async def get_assets_paginated(limit: int = 100, offset: int = 0) -> tuple[list[
|
|||||||
async with get_connection() as conn:
|
async with get_connection() as conn:
|
||||||
total = await conn.fetchval("SELECT COUNT(*) FROM assets")
|
total = await conn.fetchval("SELECT COUNT(*) FROM assets")
|
||||||
rows = await conn.fetch(
|
rows = await conn.fetch(
|
||||||
"""SELECT name, content_hash, asset_type, tags, metadata, url,
|
"""SELECT name, content_hash, ipfs_cid, asset_type, tags, metadata, url,
|
||||||
provenance, description, origin, owner, created_at, updated_at
|
provenance, description, origin, owner, created_at, updated_at
|
||||||
FROM assets ORDER BY created_at DESC LIMIT $1 OFFSET $2""",
|
FROM assets ORDER BY created_at DESC LIMIT $1 OFFSET $2""",
|
||||||
limit, offset
|
limit, offset
|
||||||
@@ -237,7 +237,7 @@ async def get_assets_by_owner(owner: str) -> dict[str, dict]:
|
|||||||
"""Get all assets owned by a user."""
|
"""Get all assets owned by a user."""
|
||||||
async with get_connection() as conn:
|
async with get_connection() as conn:
|
||||||
rows = await conn.fetch(
|
rows = await conn.fetch(
|
||||||
"""SELECT name, content_hash, asset_type, tags, metadata, url,
|
"""SELECT name, content_hash, ipfs_cid, asset_type, tags, metadata, url,
|
||||||
provenance, description, origin, owner, created_at, updated_at
|
provenance, description, origin, owner, created_at, updated_at
|
||||||
FROM assets WHERE owner = $1 ORDER BY created_at DESC""",
|
FROM assets WHERE owner = $1 ORDER BY created_at DESC""",
|
||||||
owner
|
owner
|
||||||
|
|||||||
Reference in New Issue
Block a user