percentile stat of 0 if no contributions

This commit is contained in:
talksik
2019-05-07 14:47:25 -07:00
parent 8eac71b47c
commit 98485a0da0
+4 -1
View File
@@ -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