Files
pages/internal/store/preview_candidates.go
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

55 lines
1.1 KiB
Go

package store
func (s *Store) ListPreviewCandidatesInDomain(
domainUUID string,
) ([]BrowserEntry, error) {
rows, err := s.DB.Query(`
WITH latest AS (
SELECT
r.uuid,
r.object_uuid,
COALESCE(r.document_hash, ''),
COALESCE(NULLIF(r.content_type, ''), 'application/octet-stream'),
COALESCE(r.filename, ''),
ROW_NUMBER() OVER (
PARTITION BY r.object_uuid
ORDER BY COALESCE(r.created_at_ms, r.created_at * 1000) DESC, r.rowid DESC
) AS rn
FROM revisions r
)
SELECT
p.path,
p.object_uuid,
latest.uuid,
latest.document_hash,
latest.content_type,
latest.filename
FROM paths p
JOIN latest
ON latest.object_uuid = p.object_uuid
AND latest.rn = 1
WHERE p.domain_uuid = ?
ORDER BY p.path
`, domainUUID)
if err != nil {
return nil, err
}
defer rows.Close()
var entries []BrowserEntry
for rows.Next() {
var entry BrowserEntry
if err := rows.Scan(
&entry.Path,
&entry.ObjectUUID,
&entry.RevisionUUID,
&entry.DocumentHash,
&entry.ContentType,
&entry.Filename,
); err != nil {
return nil, err
}
entries = append(entries, entry)
}
return entries, rows.Err()
}