mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
refactor(api): improve function naming in spotify source
This commit is contained in:
parent
5ca3437b59
commit
97f5ef70ac
1 changed files with 5 additions and 5 deletions
|
|
@ -32,20 +32,20 @@ export class SpotifyService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Interval(20 * 1000)
|
@Interval(20 * 1000)
|
||||||
async getRecentlyPlayedTracks(): Promise<void> {
|
async runCrawlerForAllUsers(): Promise<void> {
|
||||||
this.logger.debug("Starting Spotify crawler loop");
|
this.logger.debug("Starting Spotify crawler loop");
|
||||||
const users = await this.usersService.findAll();
|
const users = await this.usersService.findAll();
|
||||||
|
|
||||||
for (const user of users) {
|
for (const user of users) {
|
||||||
await this.processUser(user);
|
await this.crawlListensForUser(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async processUser(
|
async crawlListensForUser(
|
||||||
user: User,
|
user: User,
|
||||||
retryOnExpiredToken: boolean = true
|
retryOnExpiredToken: boolean = true
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
this.logger.debug(`Importing recently played track for user "${user.id}"`);
|
this.logger.debug(`Crawling recently played tracks for user "${user.id}"`);
|
||||||
|
|
||||||
let playHistory: PlayHistoryObject[];
|
let playHistory: PlayHistoryObject[];
|
||||||
try {
|
try {
|
||||||
|
|
@ -59,7 +59,7 @@ export class SpotifyService {
|
||||||
...user.spotify,
|
...user.spotify,
|
||||||
accessToken,
|
accessToken,
|
||||||
});
|
});
|
||||||
await this.processUser(user, false);
|
await this.crawlListensForUser(user, false);
|
||||||
} else {
|
} else {
|
||||||
// TODO sent to sentry
|
// TODO sent to sentry
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue