Exemple #1
0
 def _insert_country_vectors(self):
     session.query(CountryVector).delete()
     for country_id, country_vector in self.implicit_mf.country_vectors.vectors.iterrows(
     ):
         session.add(
             CountryVector(country_id=int(country_id), **country_vector))
     session.commit()
Exemple #2
0
def insert_countries():
    for country_name in countries.keys():
        country = Country(id=countries[country_name]['id'],
                          name=country_name,
                          value=country_name)
        session.add(country)
    session.commit()
Exemple #3
0
def insert_operators():
    for operator_id in OPERATORS.keys():
        operator = Operator(id=operator_id,
                            name=OPERATORS[operator_id]['name'],
                            value=OPERATORS[operator_id]['value'])
        session.add(operator)
    session.commit()
Exemple #4
0
 def _setUp_songs(self):
     for song_id, song in DUMMY_SONGS.iterrows():
         session.add(
             Song(id=int(song_id),
                  title=song['Track Name'],
                  artist=song['Artist'],
                  url=song['URL']))
     session.commit()
Exemple #5
0
def insert_operators():
    for operator_id in OPERATORS.keys():
        operator = Operator(
            id=operator_id,
            name=OPERATORS[operator_id]['name'],
            value=OPERATORS[operator_id]['value']
        )
        session.add(operator)
    session.commit()
Exemple #6
0
def insert_countries():
    for country_name in countries.keys():
        country = Country(
            id=countries[country_name]['id'],
            name=country_name,
            value=country_name
        )
        session.add(country)
    session.commit()
Exemple #7
0
    def run(self, date):
        for country_name in countries.keys():
            top_songs_generator = TopSongsGenerator(country_name=country_name, date=date)
            if not top_songs_generator.daily_chart.dataframe.empty:

                for top_song in top_songs_generator:
                    if not self._top_song_exists(top_song):
                        session.add(top_song)

                session.commit()
Exemple #8
0
 def _insert_song_vectors(self):
     session.query(SongVector).delete()
     for song_id, song_vector in self.implicit_mf.song_vectors.vectors.iterrows(
     ):
         session.add(SongVector(song_id=int(song_id), **song_vector))
     session.commit()
Exemple #9
0
 def tearDown(self):
     session.query(CountryVector).delete()
     session.query(SongVector).delete()
     session.query(Song).delete()
     session.commit()
Exemple #10
0
def insert_top_songs():
    for country_name in countries.keys():
        for top_song in TopSongsGenerator(country_name):
            session.add(top_song)
    session.commit()
Exemple #11
0
 def _insert_song_vectors(self):
     session.query(SongVector).delete()
     for song_id, song_vector in self.implicit_mf.song_vectors.vectors.iterrows():
         session.add(SongVector(song_id=int(song_id), **song_vector))
     session.commit()
Exemple #12
0
 def _insert_country_vectors(self):
     session.query(CountryVector).delete()
     for country_id, country_vector in self.implicit_mf.country_vectors.vectors.iterrows():
         session.add(CountryVector(country_id=int(country_id), **country_vector))
     session.commit()