Commit 49771768 authored by Guillermo Sanz López's avatar Guillermo Sanz López
Browse files

change getNum function providers

parent 2f9eed50
Loading
Loading
Loading
Loading
+3 −28
Original line number Diff line number Diff line
@@ -111,34 +111,9 @@ class Operations:
            return "Error when retreiving provider list: ", e
        
    def get_num_providers(self):

        mycol = self.db.get_col_by_name(self.db.providers)
        user_col = self.db.get_col_by_name_register(self.db.user)

        try:

            users = user_col.find({}, {"_id": 0})
            providers = mycol.find({}, {"_id": 0})

            json_providers = []
            for provider in providers:
                # user = user_col.find({
                # "list_providers": provider["api_prov_dom_id"]
                # }, 
                # {"_id": 0})
                # provider.update(user)
                for user in users:
                    if provider["api_prov_dom_id"] in user["list_providers"]:
                        provider["username"]=user["username"]
                json_providers.append(provider)

            #return jsonify(message="Providers retrieved succesfully",
            #               object=json_providers), 200
            #return jsonify(json_providers), 200
        json_providers = Operations.get_providers()
        num_providers = len(json_providers)
        return jsonify(num_providers), 200
        except Exception as e:
            return "Error when retreiving provider list: ", e

    def get_provider_services(self, id):