Collection page shows a different dataset count in the card and the results header

Open Beginner friendly
#6,566 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python

Research direction

Read app/routes.py and app/templates/index.html, then compare the count handling with collection_card.html and the dataset page’s parent record adjustment. Use the search result’s total for the collection count and fix the header plural; add a test for a collection with more than 20 datasets. Done when both displayed counts show the total and the header uses the correct plural.

Written by the indexing model from the issue text.

Description

bug

On a collection page, the collection card at the top caps its dataset count at 20, while the results header just below shows the real total. Collections with more than 20 datasets show two different numbers.

  • Environment: prod catalog.data.gov
  • Component: datagov-catalog, collection view (/?collection=<identifier>)
  • Example: https://catalog.data.gov/?collection=US-GOV-SSA-314 (SSI Annual Statistical Report series). The card says "20 datasets in this collection", the results header says "24 dataset in this collection". The collection has 24 datasets (2002 to 2025).

How to reproduce

  1. Open https://catalog.data.gov/?collection=US-GOV-SSA-314, or click "Explore Collection" on https://catalog.data.gov/dataset/ssi-annual-statistical-report-series
  2. Compare the count in the collection card with the count in the results header below it.

Expected behavior

  • Both counts show 24.
  • The header reads "24 datasets", plural.

Actual behavior

  • The card shows 20. app/routes.py sets collection_data["count"] to len(interface.search_datasets(...).results), which is the length of one page of results (20 by default), not the total.
  • The header says "24 dataset" because app/templates/index.html uses {{s if total > 1 }}, where s is an undefined variable rather than the string "s".

Sketch

  • Use the search result's total for the collection count instead of the length of results (check whether the parent record needs to be excluded, as the dataset page does with result.total - 1)
  • Fix the plural in index.html to {{ "s" if total != 1 }}, matching collection_card.html
  • Add a test with a collection of more than 20 datasets
Dominant language
Python
Stars
1.2k
Forks
207
Avg merge
3d 16h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GSA/data.gov

All issues in GSA/data.gov

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.