percentile stat of 0 if no contributions
This commit is contained in:
@@ -103,7 +103,10 @@ exports.getDashboardData = async (req, res, next) => {
|
||||
|
||||
donors.map((donor, index) => {
|
||||
if (donor.id == donor_id) {
|
||||
let percentile = (number_donors - index) / number_donors;
|
||||
const donor_contributions = donor.total_contributions;
|
||||
|
||||
let percentile =
|
||||
donor_contributions > 0 ? (number_donors - index) / number_donors : 0;
|
||||
return res.status(200).json({
|
||||
message: 'Successfully got the stats',
|
||||
percentile
|
||||
|
||||
Reference in New Issue
Block a user