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."""
|
||||
async with get_connection() as conn:
|
||||
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
|
||||
FROM assets WHERE name = $1""",
|
||||
name
|
||||
@@ -199,7 +199,7 @@ async def get_asset_by_hash(content_hash: str) -> Optional[dict]:
|
||||
"""Get asset by content hash."""
|
||||
async with get_connection() as conn:
|
||||
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
|
||||
FROM assets WHERE content_hash = $1""",
|
||||
content_hash
|
||||
@@ -213,7 +213,7 @@ async def get_all_assets() -> dict[str, dict]:
|
||||
"""Get all assets as a dict indexed by name."""
|
||||
async with get_connection() as conn:
|
||||
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
|
||||
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:
|
||||
total = await conn.fetchval("SELECT COUNT(*) FROM assets")
|
||||
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
|
||||
FROM assets ORDER BY created_at DESC LIMIT $1 OFFSET $2""",
|
||||
limit, offset
|
||||
@@ -237,7 +237,7 @@ async def get_assets_by_owner(owner: str) -> dict[str, dict]:
|
||||
"""Get all assets owned by a user."""
|
||||
async with get_connection() as conn:
|
||||
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
|
||||
FROM assets WHERE owner = $1 ORDER BY created_at DESC""",
|
||||
owner
|
||||
|
||||
Reference in New Issue
Block a user