Skip to content

feat(custom-fields): add usage count column to Custom Fields list#2250

Merged
DonKoko merged 3 commits intomainfrom
claude/add-field-usage-count-ytVqh
Jan 7, 2026
Merged

feat(custom-fields): add usage count column to Custom Fields list#2250
DonKoko merged 3 commits intomainfrom
claude/add-field-usage-count-ytVqh

Conversation

@carlosvirreira
Copy link
Copy Markdown
Contributor

Summary

Add a "Used on" column to the Custom Fields settings page that displays
the number of assets using each custom field. This helps admins identify
unused or underutilized custom fields that may create UI clutter.

Changes

  • Enhanced getFilteredAndPaginatedCustomFields() service to fetch usage
    counts using Prisma groupBy query on AssetCustomFieldValue table
  • Added "Used on" column to Custom Fields list table header
  • Display usage count in TeamMemberRow component with proper formatting:
    • "0 assets" for unused fields
    • "1 asset" for single use
    • "X assets" for multiple uses
  • Optimized query performance by grouping counts in a single database call

Implementation Details

The usage count is computed by counting distinct assets with non-null values
for each custom field. The query runs on page load and uses an efficient
Map-based lookup to attach counts to custom field records.

Acceptance Criteria Met

  • Usage count visible in Custom Fields list
  • Updates on page load (real-time data)
  • Zero clearly shown for unused fields
  • Proper singular/plural formatting ("1 asset" vs "X assets")

Files Changed

  • app/modules/custom-field/service.server.ts
  • app/routes/_layout+/settings.custom-fields.index.tsx

claude added 2 commits January 6, 2026 14:40
Add a "Used on" column to the Custom Fields settings page that displays
the number of assets using each custom field. This helps admins identify
unused or underutilized custom fields that may create UI clutter.

The count is computed by querying the AssetCustomFieldValue table and
grouping by customFieldId. The count updates on page load and shows
"0 assets" for unused fields, "1 asset" for single use, or "X assets"
for multiple uses.

Changes:
- Update getFilteredAndPaginatedCustomFields service to fetch and attach
  usage counts using Prisma groupBy query
- Add "Used on" column header in the Custom Fields list UI
- Display usage count in TeamMemberRow component with proper formatting
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
shelf-docs Ignored Ignored Preview Jan 7, 2026 9:31am

DonKoko
DonKoko previously approved these changes Jan 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a "Used on" column to the Custom Fields settings page to display how many assets are using each custom field. This helps administrators identify unused or underutilized custom fields that may contribute to UI clutter.

Key changes:

  • Enhanced the getFilteredAndPaginatedCustomFields() service to compute usage counts via a Prisma groupBy query on AssetCustomFieldValue records
  • Added a new "Used on" table column with proper singular/plural formatting ("1 asset" vs "X assets")
  • Updated TypeScript types to include usageCount in the custom field payload

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
app/modules/custom-field/service.server.ts Added parallel query to fetch usage counts using groupBy, created a Map for efficient lookup, and attached counts to custom field records
app/routes/_layout+/settings.custom-fields.index.tsx Added "Used on" column header, updated TypeScript type definition to include usageCount, and implemented conditional formatting for the count display

Comment thread app/routes/_layout+/settings.custom-fields.index.tsx Outdated
Comment thread app/modules/custom-field/service.server.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@DonKoko DonKoko merged commit 753d1c9 into main Jan 7, 2026
7 checks passed
@carlosvirreira
Copy link
Copy Markdown
Contributor Author

thanks for deploying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants