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

🐛 Handle "or" behavior for specified metric types #890

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

jeremyf
Copy link
Contributor

@jeremyf jeremyf commented Oct 30, 2023

Prior to this commit, when you provided an explicit
metric_type=total_item_requests you would get back the various data
types that had been seeded in the database.

When you'd provide the metric_type=searches_platform you would see the
DataType for the Platform (and not the Article nor Book data types).

When you'd provide ``metric_type=searches_platform|total_item_requestsyou would only get thePlatform` data type.

The expected behavior is you would get the Article, Book, and
Platform data types.

This commit remedies that behavior. Note, dear reader, that the test
case only has article in the given date range.

See the Sushi Docs:

Copied text from Issue

In https://pittir.commons-archive.org/api/sushi/r51/reports/pr?begin_date=2023-06&end_date=2023-07&metric_type=total_item_requests , the output includes:

      {
        "Data_Type": "article",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 700,
            "2023-07": 740
          }
        }
      },
      {
        "Data_Type": "book",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 175,
            "2023-07": 187
          }
        }
      }

The for the same timeframe, https://pittir.commons-archive.org/api/sushi/r51/reports/pr?begin_date=2023-06&end_date=2023-07&metric_type=Searches_Platform includes:

      {
        "Data_Type": "Platform",
        "Access_Method": "Regular",
        "Performance": {
          "Searches_Platform": {
            "2023-06": 806,
            "2023-07": 833
          }
        }
      }

so, an "OR" of the two parameters (metric_type=Searches_Platform|total_item_requests) should include both Metric Types (from any Data Types, since data_type is not filtered):

      {
        "Data_Type": "article",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 700,
            "2023-07": 740
          }
        }
      },
      {
        "Data_Type": "book",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 175,
            "2023-07": 187
          }
        }
      },
      {
        "Data_Type": "Platform",
        "Access_Method": "Regular",
        "Performance": {
          "Searches_Platform": {
            "2023-06": 806,
            "2023-07": 833
          }
        }
      }

instead, https://pittir.commons-archive.org/api/sushi/r51/reports/pr?begin_date=2023-06&end_date=2023-07&metric_type=Searches_Platform|total_item_requests only includes Searches Platform from the Platform Data Type:

  "Report_Items": {
    "Platform": "pittir.commons-archive.org",
    "Attribute_Performance": [
      {
        "Data_Type": "Platform",
        "Access_Method": "Regular",
        "Performance": {
          "Searches_Platform": {
            "2023-06": 806,
            "2023-07": 833
          }
        }
      }
    ]
  }

Related to:


Story

Refs #issuenumber

Expected Behavior Before Changes

Expected Behavior After Changes

Screenshots / Video

Notes

Prior to this commit, when you provided an explicit
`metric_type=total_item_requests` you would get back the various data
types that had been seeded in the database.

When you'd provide the `metric_type=searches_platform` you would see the
DataType for the `Platform` (and not the Article nor Book data types).

When you'd provide ``metric_type=searches_platform|total_item_requests`
you would only get the `Platform` data type.

The expected behavior is you would get the `Article`, `Book`, and
`Platform` data types.

This commit remedies that behavior.  Note, dear reader, that the test
case only has `article` in the given date range.

See the Sushi Docs:

- https://countermetrics.stoplight.io/docs/counter-sushi-api/e98e9f5cab5ed-pr-platform-report

<details>
<summary>Copied text from Issue</summary>

In https://pittir.commons-archive.org/api/sushi/r51/reports/pr?begin_date=2023-06&end_date=2023-07&metric_type=total_item_requests , the output includes:
```
      {
        "Data_Type": "article",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 700,
            "2023-07": 740
          }
        }
      },
      {
        "Data_Type": "book",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 175,
            "2023-07": 187
          }
        }
      }
```
The for the same timeframe, https://pittir.commons-archive.org/api/sushi/r51/reports/pr?begin_date=2023-06&end_date=2023-07&metric_type=Searches_Platform includes:
```
      {
        "Data_Type": "Platform",
        "Access_Method": "Regular",
        "Performance": {
          "Searches_Platform": {
            "2023-06": 806,
            "2023-07": 833
          }
        }
      }
```
so, an "OR" of the two parameters (`metric_type=Searches_Platform|total_item_requests`) should include both Metric Types (from any Data Types, since data_type is not filtered):
```
      {
        "Data_Type": "article",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 700,
            "2023-07": 740
          }
        }
      },
      {
        "Data_Type": "book",
        "Access_Method": "Regular",
        "Performance": {
          "Total_Item_Requests": {
            "2023-06": 175,
            "2023-07": 187
          }
        }
      },
      {
        "Data_Type": "Platform",
        "Access_Method": "Regular",
        "Performance": {
          "Searches_Platform": {
            "2023-06": 806,
            "2023-07": 833
          }
        }
      }
```
instead, https://pittir.commons-archive.org/api/sushi/r51/reports/pr?begin_date=2023-06&end_date=2023-07&metric_type=Searches_Platform|total_item_requests only includes Searches Platform from the Platform Data Type:
```
  "Report_Items": {
    "Platform": "pittir.commons-archive.org",
    "Attribute_Performance": [
      {
        "Data_Type": "Platform",
        "Access_Method": "Regular",
        "Performance": {
          "Searches_Platform": {
            "2023-06": 806,
            "2023-07": 833
          }
        }
      }
    ]
  }
```

</details>

Related to:

- #686 (comment)
@jeremyf jeremyf merged commit b987092 into main Oct 30, 2023
6 of 7 checks passed
@jeremyf jeremyf deleted the i686-or-conditions branch October 30, 2023 21:18
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