-
Notifications
You must be signed in to change notification settings - Fork 191
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
Feature: Add endpoint for Campaign Overview Statistics #7545
Feature: Add endpoint for Campaign Overview Statistics #7545
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjohnson Great work! I left a few comments related to some minor changes, but also would like to suggest something that I think would be helpful.
I think we need to add a dateRange
property in the route returns, something like this:
// "All time"
[
[
'dateRange' => ['startDate' => '0', 'endDate' => '0']
'amountRaised' => 20,
'donationCount' => 2,
'donorCount' => 2,
],
]
// Period of time with previous period
[
[
// Current period
'dateRange' => ['startDate' => 'value', 'endDate' => 'value']
'amountRaised' => 20,
'donationCount' => 2,
'donorCount' => 2,
],
[
// Previous period
'dateRange' => ['startDate' => 'value', 'endDate' => 'value']
'amountRaised' => 10,
'donationCount' => 1,
'donorCount' => 1,
],
]
I was checking the code using PHP XDebug and took a while to understand the testReturnsPeriodStatisticsWithPreviousPeriod()
without this information, so I think it can be used in future debug sessions and also can be helpful to have this information on the JS side.
@glaubersilva the intention of the data format is to be a queue of data, so the current is always first and moves backwards one period per item in the array. This could be better documented or made more clear. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjohnson Great work!
Related GIVE-1221
Related GIVE-1222
Description
This PR adds the
GET \give-api\v2\campaign-overview-statistics
endpoint for fetching campaign statistics, such as Amount Raised, Donation Count, and Donor Count.If a range in days (
rangeInDays
) is provided then a pair of values are returned to include the previous period of the range.Affects
Campaigns\CampaignDonationQuery
has been updated with support for immutability.Framework\Support\Facades\DateTime\TemporalFacade
has been updated to include new helper methodswithStartOfDay
andwithEndOfDay
, which set the appropriate time for inclusively querying dates in a range. Additionally, theimmutableOrClone
method has been added to encapsulate support for immutability that accounts for eitherDateTime
orDateTimeImmutable
, both of which implement theDateTimeInterface
.Framework\Support\Facades\DateTime\Temporal
has been updated with available methods using@method
annotations in the docblock.Visuals
Pre-review Checklist
@unreleased
tags included in DocBlocks