feat: expose file attachment stats as item properties/columns #37

Closed
opened 2026-02-08 21:28:53 +00:00 by forbes · 0 comments
Owner

Summary

Surface file attachment metadata and ensure item modification tracking covers all data changes, available as columns in the items table.

Motivation

Users need to see at a glance which items have files attached, how many, and how large they are — without opening each item's detail view. The item's updated_at timestamp should also reflect any change to the item's data (properties, revisions, files, BOM entries, project tags), not just direct item edits.

Proposed Properties

Property Type Description
file_count integer Number of files associated with the item
files_total_size integer (bytes) Sum of all associated file sizes
files_latest_upload timestamp Most recent file upload date
files_latest_modified timestamp Most recent file modified date (from file metadata)

Item updated_at Scope

The item's updated_at column already exists but should be touched whenever any related data changes:

  • Item properties updated (already works)
  • Revision created/updated/rolled back
  • File uploaded, associated, or removed
  • BOM entry added, updated, or removed
  • Project tag added or removed

This ensures sorting by "last modified" in the items table gives meaningful results.

Implementation Notes

  • File stats could be computed via JOIN on the item_files table when listing items, or maintained as a materialized/cached value
  • updated_at touch: add UPDATE items SET updated_at = now() WHERE part_number = ... to each relevant handler, or use DB triggers
  • Frontend: add optional columns to the items table (hidden by default, togglable via column visibility)
  • API: include file stats in GET /api/items and GET /api/items/{pn} responses
  • Consider sort/filter support (e.g., sort by file count to find items missing attachments)
## Summary Surface file attachment metadata and ensure item modification tracking covers all data changes, available as columns in the items table. ## Motivation Users need to see at a glance which items have files attached, how many, and how large they are — without opening each item's detail view. The item's `updated_at` timestamp should also reflect *any* change to the item's data (properties, revisions, files, BOM entries, project tags), not just direct item edits. ## Proposed Properties | Property | Type | Description | |----------|------|-------------| | `file_count` | integer | Number of files associated with the item | | `files_total_size` | integer (bytes) | Sum of all associated file sizes | | `files_latest_upload` | timestamp | Most recent file upload date | | `files_latest_modified` | timestamp | Most recent file modified date (from file metadata) | ## Item `updated_at` Scope The item's `updated_at` column already exists but should be touched whenever any related data changes: - Item properties updated (already works) - Revision created/updated/rolled back - File uploaded, associated, or removed - BOM entry added, updated, or removed - Project tag added or removed This ensures sorting by "last modified" in the items table gives meaningful results. ## Implementation Notes - File stats could be computed via JOIN on the item_files table when listing items, or maintained as a materialized/cached value - `updated_at` touch: add `UPDATE items SET updated_at = now() WHERE part_number = ...` to each relevant handler, or use DB triggers - Frontend: add optional columns to the items table (hidden by default, togglable via column visibility) - API: include file stats in `GET /api/items` and `GET /api/items/{pn}` responses - Consider sort/filter support (e.g., sort by file count to find items missing attachments)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#37