Skip to content

Add GET endpoint for retrieving basic VegBank stats#307

Merged
regetz merged 3 commits intodevelopfrom
feature-306-get-basic-vb-stats
Feb 11, 2026
Merged

Add GET endpoint for retrieving basic VegBank stats#307
regetz merged 3 commits intodevelopfrom
feature-306-get-basic-vb-stats

Conversation

@regetz
Copy link
Contributor

@regetz regetz commented Feb 10, 2026

What

This PR adds a GET /overview endpoint that queries VegBank for some basic stats, largely mirroring what the original VegBank site reported:

  • Counts of observations, plants, and communities (and a few subsets thereof)
  • "Top N" counts of communities, plants, projects, contributors/parties, and places
  • Most recent N projects based on plot upload date

Note that this is somewhat simplistic and brute force insofar as it just does a bunch of separate queries and then collects the results into a JSON object, but the driving priority is to stand up a functional endpoint for the web UI to use.

Why

Mostly so we can throw this onto the main landing (overview) page of the web app, but also so that clients can get some basic insights into VegBank holdings with a single API call.

How

  • Added a new route and view function
  • Also moved a couple of helper methods out of the base Operator class and into the utilities module

Documentation and tested

  • Manually verified that the endpoint works as expected
  • Updated the OAS document to fully document the new endpoint and its (JSON) response schema
  • Locally verified that the JSON response can be parsed easily and nicely into list of R data frames

Demo

$ http GET 'http://127.0.0.1:8080/overview?limit=2'
{
    "core_counts": [
        {
            "count": 116352,
            "name": "Observations"
        },
        {
            "count": 95318,
            "name": "Classified observations"
        },
        {
            "count": 30436,
            "name": "NVC classified observations"
        },
        {
            "count": 293172,
            "name": "Plants"
        },
        {
            "count": 97024,
            "name": "Accepted USDA plants"
        },
        {
            "count": 9405,
            "name": "Observed accepted USDA plants"
        },
        {
            "count": 38981,
            "name": "Communities"
        },
        {
            "count": 10711,
            "name": "Accepted US NVC communities"
        },
        {
            "count": 1912,
            "name": "Observed accepted US NVC communities"
        }
    ],
    "latest_n_projects": [
        {
            "last_date_added": "Thu, 30 Apr 2020 16:17:56 GMT",
            "name": "NVC Plot Template Import NCCN_plus_External_Sources_Plot_Data",
            "count": 3538,
            "pj_code": "pj.11129"
        },
        {
            "last_date_added": "Wed, 25 Apr 2018 18:39:54 GMT",
            "name": "Canadian Transect_Grizelle Gonzalez (Gonzalez et al. 2000)",
            "count": 113,
            "pj_code": "pj.11111"
        }
    ],
    "top_n_community_concepts": [
        {
            "cc_code": "cc.30623",
            "count": 1961,
            "name": "Artemisia tridentata ssp. wyomingensis Shrubland Alliance"
        },
        {
            "cc_code": "cc.30769",
            "count": 1696,
            "name": "Pinus ponderosa Woodland Alliance"
        }
    ],
    "top_n_contributors": [
        {
            "count": 10283,
            "name": "Peet, Robert",
            "py_code": "py.191310"
        },
        {
            "count": 8657,
            "name": "Jennings, Michael",
            "py_code": "py.415"
        }
    ],
    "top_n_named_places": [
        {
            "count": 16492,
            "name": "Nevada",
            "np_code": "np.395"
        },
        {
            "count": 12808,
            "name": "California",
            "np_code": "np.366"
        }
    ],
    "top_n_plant_concepts": [
        {
            "count": 7475,
            "name": "Pseudotsuga menziesii (Mirbel) Franco",
            "pc_code": "pc.47659"
        },
        {
            "count": 7073,
            "name": "Acer rubrum",
            "pc_code": "pc.110065"
        }
    ],
    "top_n_projects": [
        {
            "count": 17326,
            "name": "Southwest GAP, Nevada",
            "pj_code": "pj.10510"
        },
        {
            "count": 12962,
            "name": "Composition and function of vegetation alliances in the Interior Northwest, USA",
            "pj_code": "pj.339"
        }
    ]
}

@regetz regetz self-assigned this Feb 10, 2026
Copy link
Contributor

@RWShelton RWShelton left a comment

Choose a reason for hiding this comment

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

Structure looks good from my point of view, if this has all the fields the front end needs I'd say its good to go.

Copy link

@DarianGill DarianGill left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for adding the latest N projects!

@regetz regetz merged commit d129de9 into develop Feb 11, 2026
2 checks passed
@regetz regetz linked an issue Feb 11, 2026 that may be closed by this pull request
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.

Add an endpoint for basic VegBank stats

3 participants

Comments