use of com.github.hakko.musiccabinet.parser.lastfm.GroupWeeklyArtistChartParserImpl in project musiccabinet by hakko.
the class JdbcGroupWeeklyArtistChartDaoTest method loadFunctionDependency.
@Before
public void loadFunctionDependency() throws ApplicationException {
PostgreSQLUtil.loadFunction(dao, UPDATE_GROUP_WEEKLY_ARTIST_CHART);
PostgreSQLUtil.loadFunction(dao, UPDATE_LASTFMGROUP);
artistChart = new GroupWeeklyArtistChart(brainwashed.getName(), new GroupWeeklyArtistChartParserImpl(new ResourceUtil(BRAINWASHED_FILE).getInputStream()).getArtistPlayCount());
Collections.sort(artistChart.getArtistPlayCounts());
createArtistMetaData();
}
use of com.github.hakko.musiccabinet.parser.lastfm.GroupWeeklyArtistChartParserImpl in project musiccabinet by hakko.
the class GroupWeeklyArtistChartService method updateSearchIndex.
@Override
public void updateSearchIndex() throws ApplicationException {
List<GroupWeeklyArtistChart> artistCharts = new ArrayList<>();
List<LastFmGroup> groups = lastFmDao.getLastFmGroups();
setTotalOperations(groups.size());
for (LastFmGroup group : groups) {
try {
WSResponse wsResponse = client.getWeeklyArtistChart(group);
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
GroupWeeklyArtistChartParser parser = new GroupWeeklyArtistChartParserImpl(stringUtil.getInputStream());
artistCharts.add(new GroupWeeklyArtistChart(group.getName(), parser.getArtistPlayCount()));
}
} catch (ApplicationException e) {
LOG.warn("Fetching weekly artist chart for " + group.getName() + " failed.", e);
}
addFinishedOperation();
}
dao.createArtistCharts(artistCharts);
}
Aggregations