Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GET "/api/ca_dashboard/stats" endpoint #852

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

aaronskiba
Copy link
Collaborator

@aaronskiba aaronskiba commented Aug 13, 2024

Changes proposed in this PR:

  • Add GET "/api/ca_dashboard/stats" endpoint to fetch "stats"
  • The following is an example JSON response returned after a proper request to GET "/api/ca_dashboard/stats":
    {
        "application": "DMP Assistant",
        "source": "GET /api/ca_dashboard/stats",
        "time": "2024-08-14T18:53:15-06:00",
        "caller": "DMP Administrator",
        "code": 200,
        "message": "OK",
        "total_items": 0,
        "stats": {
            "totals": {
                "all_time": {
                    "plans": 13696,
                    "orgs": 127,
                    "users": 17823
                },
                "last_30_days": {
                    "plans": 0,
                    "orgs": 0,
                    "users": 0
                },
                "custom_range": {
                    "plans": 2429,
                    "orgs": 27,
                    "users": 1848
                }
            }
        }
    }
    • The "custom_range": { "plans": 2429, "orgs": 27, "users": 1848 } part of the above JSON structure is only returned when the user specifies a valid start and/or end parameter when making the API request. Otherwise, the following JSON structure is returned:
    {
        "application": "DMP Assistant",
        "source": "GET /api/ca_dashboard/stats",
        "time": "2024-08-14T19:04:31-06:00",
        "caller": "DMP Administrator",
        "code": 200,
        "message": "OK",
        "total_items": 0,
        "stats": {
            "totals": {
                "all_time": {
                    "plans": 13696,
                    "orgs": 127,
                    "users": 17823
                },
                "last_30_days": {
                    "plans": 0,
                    "orgs": 0,
                    "users": 0
                }
            }
        }
    }

@aaronskiba aaronskiba marked this pull request as draft August 14, 2024 17:08
@aaronskiba aaronskiba changed the title Create GET "/api/dmp_assistant/stats" endpoint Create GET "/api/ca_dashboard/stats" endpoint Aug 15, 2024
@aaronskiba aaronskiba marked this pull request as ready for review August 15, 2024 20:21

json.partial! 'api/v1/standard_response'
json.stats do
json.totals @totals
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a quick question @aaronskiba , why do we have the value "total_items": 0, in the resulting json output?

Is that something we need ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question; I guess that's just being inherited from api/v1/standard_response. I think it corresponds to the number of plans returned, which would always be zero for this new API endpoint:

I guess it does a similar thing when I check api/v1/heartbeat:

{
  "application": "DMP Assistant",
  "source": "GET /api/v1/heartbeat",
  "time": "2024-08-29T18:21:17+00:00",
  "caller": "142.244.108.150",
  "code": 200,
  "message": "OK",
  "total_items": 0,
  "items": [
  ]
}

Here's an API request for a specific plan:

{
  "application": "DMP Assistant",
  "source": "GET /api/v1/plans/id_redacted",
  "time": "2024-08-29T18:18:34+00:00",
  "caller": "DMP Administrator",
  "code": 200,
  "message": "OK",
  "page": 1,
  "per_page": 100,
  "total_items": 1,
  "items": [
    {
      "dmp": {
        "schema": "https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard/tree/master/examples/JSON/JSON-schema/1.0",
        "title": "v4.1.3 Test"
...

Copy link
Collaborator

@lagoan lagoan left a comment

Choose a reason for hiding this comment

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

LGTM

@aaronskiba aaronskiba merged commit 04f2e21 into integration Aug 29, 2024
9 of 11 checks passed
@aaronskiba aaronskiba deleted the aaron/stats-api branch August 29, 2024 21:33
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.

2 participants