Esempio n. 1
0
 def donate(items):
     collection = DonateService.get_collection()
     donation = DonateService.get(items.get('donatedBy'))
     if not donation:
         return BaseMongo.insert(collection, items)
     filters = {'_id': ObjectId(donation.get('id'))}
     return BaseMongo.replace_one(collection, filters, items)
Esempio n. 2
0
 def get_donor_recommendations(essential_ids):
     collection = DonateService.get_collection()
     items_filter = [{
         "items.itemId": essential_id
     } for essential_id in essential_ids]
     filters = {}
     if items_filter:
         filters["$or"] = items_filter
     return BaseMongo.find_all(collection, filters)
    def get_clusters(coordinate):
        issues_collection = IssuesService.get_collection()
        filters = IssuesService.__build_aggregate_location_filters(coordinate)

        cursor = BaseMongo.aggregate(issues_collection, filters)

        documents = list()
        for document in cursor:
            new_document = {}
            new_document['distance'] = document.pop("_id")
            new_document['count'] = document['count']
            docs = document.get('docs')
            for doc in docs:
                doc["id"] = str(doc.pop("_id"))
            new_document['issues'] = docs
            documents.append(new_document)

        return documents
Esempio n. 4
0
 def get_all_acknowledgements_for_the_volunteer(volunteer_id):
     collection = IssuesAcknowledgementsService.get_collection()
     filters = {'volunteer_id': volunteer_id}
     return BaseMongo.find_all(collection, filters)
 def add_issue(issue):
     essential_collection = IssuesService.get_collection()
     return BaseMongo.insert(essential_collection, issue)
 def get_by_email(email):
     volunteer_collection = VolunteersService.get_collection()
     return BaseMongo.find_one(volunteer_collection, {'emailId': email})
 def get(name):
     essential_collection = EssentialsService.get_collection()
     essentials = BaseMongo.find_one(essential_collection,
                                     {'name': name.lower()})
     return essentials
Esempio n. 8
0
 def add_victim(victim):
     collection = VictimsService.get_collection()
     return BaseMongo.insert(collection, victim)
 def get_all():
     collection = VolunteersService.get_collection()
     return BaseMongo.find_all(collection)
 def add_plus_one(issue_victim_plus_one_mapping):
     collection = IssuesPlusOneService.get_collection()
     return BaseMongo.insert(collection, issue_victim_plus_one_mapping)
 def get_by_id(issue_id):
     essential_collection = IssuesService.get_collection()
     essentials = BaseMongo.find_one(essential_collection, {'_id': ObjectId(issue_id)})
     return essentials
Esempio n. 12
0
 def get_by_id(victim_id):
     collection = ReportersService.get_collection()
     return BaseMongo.find_one(collection, {'_id': ObjectId(victim_id)})
Esempio n. 13
0
 def get_by_phone_no(phone_no):
     collection = ReportersService.get_collection()
     return BaseMongo.find_one(collection, {'phoneNo': phone_no})
Esempio n. 14
0
 def get_all():
     collection = ReportersService.get_collection()
     return BaseMongo.find_all(collection)
Esempio n. 15
0
 def add_reporter(victim):
     collection = ReportersService.get_collection()
     return BaseMongo.insert(collection, victim)
Esempio n. 16
0
 def get_all():
     collection = VictimsService.get_collection()
     return BaseMongo.find_all(collection)
 def get_all():
     essential_collection = IssuesService.get_collection()
     return BaseMongo.find_all(essential_collection)
Esempio n. 18
0
 def add_report(issue_report_mapping):
     collection = IssueReportsService.get_collection()
     return BaseMongo.insert(collection, issue_report_mapping)
 def get_all_issues_based_on_coordinates(coordinate):
     essential_collection = IssuesService.get_collection()
     filters = IssuesService.__build_location_filters(coordinate)
     return BaseMongo.find_all(essential_collection, filters)
Esempio n. 20
0
 def is_report_present(issue_id, reporter_id):
     collection = IssueReportsService.get_collection()
     filters = {'issue_id': issue_id, "reporter_id": reporter_id}
     return BaseMongo.find_one(collection, filters)
 def get_all_plus_ones_for_the_issue(issue_id):
     collection = IssuesPlusOneService.get_collection()
     filters = {'issue_id': issue_id}
     return BaseMongo.find_all(collection, filters)
 def get_by_id(essential_id):
     collection = EssentialsService.get_collection()
     return BaseMongo.find_one(collection, {'_id': ObjectId(essential_id)})
Esempio n. 23
0
 def get_all_reports_for_the_issue(issue_id):
     collection = IssueReportsService.get_collection()
     filters = {'issue_id': issue_id}
     return BaseMongo.find_all(collection, filters)
 def is_plus_one_present(issue_id, victim_id):
     collection = IssuesPlusOneService.get_collection()
     filters = {'issue_id': issue_id, "victim_id": victim_id}
     return BaseMongo.find_one(collection, filters)
 def add_volunteer(volunteer):
     volunteer_collection = VolunteersService.get_collection()
     return BaseMongo.insert(volunteer_collection, volunteer)
Esempio n. 26
0
 def add_acknowledgement(issue_volunteer_acknowledgement_mapping):
     collection = IssuesAcknowledgementsService.get_collection()
     return BaseMongo.insert(collection,
                             issue_volunteer_acknowledgement_mapping)
 def get_by_id(volunteer_id):
     volunteer_collection = VolunteersService.get_collection()
     return BaseMongo.find_one(volunteer_collection,
                               {'_id': ObjectId(volunteer_id)})
Esempio n. 28
0
 def get_all_acknowledgements_for_the_issue(issue_id):
     collection = IssuesAcknowledgementsService.get_collection()
     filters = {'issue_id': issue_id}
     return BaseMongo.find_all(collection, filters)
 def get_volunteer_id_by_phone_no(phone_no):
     volunteer_collection = VolunteersService.get_collection()
     return BaseMongo.find_one(volunteer_collection, {'phoneNo': phone_no})
Esempio n. 30
0
 def is_acknowledgement_present(issue_id, volunteer_id):
     collection = IssuesAcknowledgementsService.get_collection()
     filters = {'issue_id': issue_id, "volunteer_id": volunteer_id}
     return BaseMongo.find_one(collection, filters)