-
Notifications
You must be signed in to change notification settings - Fork 193
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
Refactor: Update goal/stats to use Donation Query #7376
Refactor: Update goal/stats to use Donation Query #7376
Conversation
public function between($startDate, $endDate) | ||
{ | ||
$this->joinMeta('_give_completed_date', 'completed'); | ||
$this->whereBetween('completed.meta_value', $startDate, $endDate); |
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.
I didn't test it on my end, but I'm very surprised that this works because the meta_value
type is longtext
and not datetime
🤔
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.
Tested this on my end and it works 😅
Interesting
$this->joinMeta('_give_payment_total', 'amount'); | ||
$this->joinMeta('_give_fee_donation_amount', 'intendedAmount'); | ||
return $this->sum( | ||
'COALESCE(intendedAmount.meta_value, amount.meta_value)' |
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.
Hmmm, I'm not sure I fully understand this.
_give_payment_total
has an amount that includes fees, and _give_fee_donation_amount
doesn't include fees.
_give_fee_donation_amount
is set only if fee recovery is checked. Correct me if I'm wrong, but COALESCE will return both _give_payment_total
and _give_fee_donation_amount
if the values are not null. So, if both are set, then the calculation is wrong, or I'm missing something?
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.
Hmm, it works as expected.
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.
I had some concerns regarding dates, but it looks like it works as expected. Also, COALESCE is doing its magic.
public function between($startDate, $endDate) | ||
{ | ||
$this->joinMeta('_give_completed_date', 'completed'); | ||
$this->whereBetween('completed.meta_value', $startDate, $endDate); |
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.
Tested this on my end and it works 😅
Interesting
$this->joinMeta('_give_payment_total', 'amount'); | ||
$this->joinMeta('_give_fee_donation_amount', 'intendedAmount'); | ||
return $this->sum( | ||
'COALESCE(intendedAmount.meta_value, amount.meta_value)' |
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.
Hmm, it works as expected.
Resolves GIVE-677
Description
This PR updates the donation goal and the donation stats for the Donation Form to use a new
DonationQuery
, which supports a date range and accounts for recovered fees.Affects
DonationQuery
class to account for recovered fees.DonationFormGoalData
DTO.getTotalRevenue
method with theDonationQuery
.getTotalRevenueForDateRange
method to the repository.getTotalNumberOfDonations
method with theDonationQuery
.getTotalNumberOfDonationsForDateRange
method to the repository.formStatsData
array to use theDonationQuery
.