Skip to content

Commit

Permalink
remved unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ritiksr25 committed Oct 1, 2019
1 parent 06293f7 commit 9600465
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions controllers/admin_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ module.exports.admin = async (req, res) => {
module.exports.volunteers = async (req, res) => {
try {
let volunteers = await Volunteer.find().sort({ createdAt: "desc" });
if (volunteers.length !== 0) {
res.status(200).json({ message: "success", volunteers });
} else {
res.status(404).json({ message: "No volunteers yet!!" });
}
res.status(200).json({ message: "success", volunteers });
} catch (err) {
res.status(500).json({ message: err.message, error: true, data: null });
}
Expand All @@ -59,7 +55,6 @@ module.exports.donors = async (req, res) => {
module.exports.bloodRequests = async (req, res) => {
try {
let requests = await BloodRequest.find().sort({ createdAt: "desc" });

res.status(200).json({ message: "success", requests });
} catch (err) {
res.status(500).json({ message: err.message, error: true, data: null });
Expand All @@ -69,11 +64,7 @@ module.exports.bloodRequests = async (req, res) => {
module.exports.messages = async (req, res) => {
try {
let messages = await Message.find().sort({ createdAt: "desc" });
if (messages.length !== 0) {
res.status(200).json({ messgae: "success", messages });
} else {
res.status(404).json({ message: "No Messages!!" });
}
} catch (err) {
res.status(500).json({ message: err.message, error: true, data: null });
}
Expand All @@ -88,9 +79,6 @@ module.exports.donations = async (req, res) => {
let donations = await Donation.find({ status: "success" }).sort({
updatedAt: "desc"
});
if (donations.length === 0) {
res.status(404).json({ message: "No Donations Yet!!" });
} else {
donations.map(donation => {
totalDonations++;
totalAmount += donation.finalAmount;
Expand All @@ -105,7 +93,6 @@ module.exports.donations = async (req, res) => {
totalDonationAmount,
totalAmount
});
}
} catch (err) {
res.status(500).json({ message: err.message, error: true, data: null });
}
Expand Down

0 comments on commit 9600465

Please sign in to comment.