def get_donor_recommendations(issue_id):
     essentials = IssuesService.get_essentials(issue_id)
     essential_ids = [essential['id'] for essential in essentials]
     donors = DonateService.get_donor_recommendations(essential_ids)
     donor_ids = [donor['donatedBy'] for donor in donors]
     donors = list()
     for donor_id in donor_ids:
         donors.append(DonarsDBService.get_by_id(donor_id))
     return donors
 def get_acknowledged_issues(volunteer_id):
     acknowledgements = IssuesAcknowledgementsService.get_all_acknowledgements_for_the_volunteer(
         volunteer_id)
     acknowledged_issue_ids = [
         acknowledgement['issue_id'] for acknowledgement in acknowledgements
     ]
     issues = IssuesService.get_all_issues()
     issues = [
         issue for issue in issues if issue['id'] in acknowledged_issue_ids
     ]
     return issues
Example #3
0
    def get(self):
        lat = request.args.get('lat')
        long = request.args.get('long')
        coordinate = {}
        if lat:
            coordinate['lat'] = lat
        if long:
            coordinate['long'] = long

        clustors_of_issues = IssuesService.get_clustors_of_issues(coordinate)
        return {'clustorsOfIssues': clustors_of_issues}
Example #4
0
    def get(self):
        lat = request.args.get('lat')
        long = request.args.get('long')
        radius = request.args.get('radius')
        coordinate = {}
        if lat:
            coordinate['lat'] = lat
        if long:
            coordinate['long'] = long
        if radius:
            coordinate['radius'] = radius

        issues = IssuesService.get_all_issues(coordinate)
        return {'issues': issues}
    def get_essential_requirements():
        issues = IssuesService.get_all_issues()
        essentials_count_maps = [{
            "essentials": issue.get('essentials', []),
            'noOfPeople': issue.get('noOfPeople', 1)
        } for issue in issues]

        essentials = {}
        for essentials_count_map in essentials_count_maps:
            for essential in essentials_count_map['essentials']:
                if not essentials.get(essential):
                    essentials[essential] = int(
                        essentials_count_map["noOfPeople"])
                else:
                    essentials[essential] += int(
                        essentials_count_map["noOfPeople"])

        essential_list = list()
        for essential_id, quantity in essentials.items():
            ess = EssentialsService.get_by_id(essential_id)
            ess['quantity'] = quantity
            essential_list.append(ess)

        return essential_list
Example #6
0
 def get(self, issue_id):
     issue = IssuesService.get_issue_by_id(issue_id)
     return issue
Example #7
0
 def post(self):
     issue = request.json
     issue_id = IssuesService.add_new_issue(issue)
     return {'status': 'success', 'insertedId': issue_id}