ci_mapping/run_pipeline.py
def geocode_affiliation(self):
        """Geocode author affiliation using Google Places API."""
        # Connect to postgresql
        s = self._create_session()

        # Fetch affiliations that have not been geocoded yet.
        queries = s.query(Affiliation.id, Affiliation.affiliation).filter(
            ~exists().where(Affiliation.id == AffiliationLocation.affiliation_id)
        )
        logger.info(f"Number of places need geocoding: {queries.count()}")

        for id, name in queries:
            r = place_by_name(name, self.google_api_key)
            if r is not None:
                response = place_by_id(r, self.google_api_key)
                place_details = parse_response(response)
                place_details.update({"affiliation_id": id})
                s.add(AffiliationLocation(**place_details))
                s.commit()
            else:
                continue
        self.next(self.open_access_journals)
        # self.next(self.end)
Geocode author affiliation using Google Places API.
Geocode author affiliation using Google Places API.
Geocode author affiliation using Google Places API .
def geocode_affiliation(self):
        s = self._create_session()
        queries = s.query(Affiliation.id, Affiliation.affiliation).filter(
            ~exists().where(Affiliation.id == AffiliationLocation.affiliation_id)
        )
        logger.info(f"Number of places need geocoding: {queries.count()}")
        for id, name in queries:
            r = place_by_name(name, self.google_api_key)
            if r is not None:
                response = place_by_id(r, self.google_api_key)
                place_details = parse_response(response)
                place_details.update({"affiliation_id": id})
                s.add(AffiliationLocation(**place_details))
                s.commit()
            else:
                continue
        self.next(self.open_access_journals)
def geocode_affiliation ( self ) : s = self . _create_session ( ) queries = s . query ( Affiliation . id , Affiliation . affiliation ) . filter ( ~ exists ( ) . where ( Affiliation . id == AffiliationLocation . affiliation_id ) ) logger . info ( f"Number of places need geocoding: {queries.count()}" ) for id , name in queries : r = place_by_name ( name , self . google_api_key ) if r is not None : response = place_by_id ( r , self . google_api_key ) place_details = parse_response ( response ) place_details . update ( { "affiliation_id" : id } ) s . add ( AffiliationLocation ( ** place_details ) ) s . commit ( ) else : continue self . next ( self . open_access_journals )
Geocode author affiliation using Google Places API.
Geocode author affiliation using Google Places API .
"""Geocode author affiliation using Google Places API.""" # Connect to postgresql # Fetch affiliations that have not been geocoded yet. # self.next(self.end)
self