···3131 sleep,
3232 sortByOldestPlayDate,
3333} from "../utils.js";
3434-import { sortByNewestPlayDate } from '../../core/PlayUtils.js';
3434+import { genGroupIdStr, sortByNewestPlayDate } from '../../core/PlayUtils.js';
3535import { formatNumber } from '../../core/DataUtils.js';
3636import { timeToHumanTimestamp } from "../../core/TimeUtils.js";
3737import { todayAwareFormat } from "../../core/TimeUtils.js";
···198198199199 protected addPlayToDiscovered = (play: PlayObject) => {
200200 const platformId = this.multiPlatform ? genGroupId(play) : SINGLE_USER_PLATFORM_ID;
201201- const list = this.recentDiscoveredPlays.get(platformId) ?? new FixedSizeList<ProgressAwarePlayObject>(200);
201201+ let list: FixedSizeList<ProgressAwarePlayObject> = this.recentDiscoveredPlays.get(platformId);
202202+ if(list === undefined) {
203203+ this.logger.trace(`Creating new discovered list for platform ${genGroupIdStr(platformId)}`);
204204+ list = new FixedSizeList<ProgressAwarePlayObject>(200);
205205+ this.recentDiscoveredPlays.set(platformId, list);
206206+ }
207207+ this.logger.trace(`Adding new discovered play to discovered list ${genGroupIdStr(platformId)} with ${list.length} existing`);
202208 list.add(play);
203203- this.recentDiscoveredPlays.set(platformId, list);
204209 this.tracksDiscovered++;
205205- this.logger.trace(new Error('addPlayToDiscovered Call site trace'));
206210 this.logger.info(`Discovered => ${buildTrackString(play)}`);
207211 this.emitEvent('discovered', {play});
208212 this.discoveredCounter.labels(this.getPrometheusLabels()).inc();
···219223 data.sort(sortByOldestPlayDate);
220224 return data;
221225 }
226226+ this.logger.trace(`Tried to get non-existent recently discovered for platform ${genGroupIdStr(platformId)}`);
222227 return [];
223228 }
224229225230 protected getExistingDiscoveredLists = (play: PlayObject, opts: {checkAll?: boolean} = {}): PlayObject[][] => {
226231 const lists: PlayObject[][] = [];
227227- if(opts.checkAll !== true) {
228228- lists.push(this.getRecentlyDiscoveredPlaysByPlatform(this.multiPlatform ? genGroupId(play) : SINGLE_USER_PLATFORM_ID));
232232+ if(opts.checkAll !== true || !this.multiPlatform) {
233233+ const plat = this.multiPlatform ? genGroupId(play) : SINGLE_USER_PLATFORM_ID;
234234+ lists.push(this.getRecentlyDiscoveredPlaysByPlatform(plat));
235235+ if(lists.every(x => x.length === 0)) {
236236+ this.logger.trace(`Got empty discovered list for platform ${genGroupIdStr(plat)}`);
237237+ }
229238 } else {
230239 // get as many as we can, optionally filtering by user
231231- this.recentDiscoveredPlays.forEach((list, platformId) => {
240240+ this.recentDiscoveredPlays.keys().forEach((platformId) => {
232241 if(play.meta.user !== undefined) {
233242 if(platformId[1] === NO_USER || platformId[1] === play.meta.user) {
234243 lists.push(this.getRecentlyDiscoveredPlaysByPlatform(platformId));
···264273265274 discover = async (plays: PlayObject[], options: { checkAll?: boolean, [key: string]: any } = {}): Promise<PlayObject[]> => {
266275267267- this.logger.trace(new Error('discover Call site trace'));
276276+ this.logger.trace(`Discover on ${plays.length} plays`);
268277 const newDiscoveredPlays: PlayObject[] = [];
269278270279 for await(const play of pMapIterable(plays, this.staggerMappers.preCompare(async x => await this.transformPlay(x, TRANSFORM_HOOK.preCompare)), {concurrency: 2})) {
+3-2
src/backend/sources/MemorySource.ts
···99 CALCULATED_PLAYER_STATUSES,
1010 InternalConfig, PlayerStateDataMaybePlay,
1111 PlayPlatformId,
1212- ProgressAwarePlayObject} from "../common/infrastructure/Atomic.js";
1212+ ProgressAwarePlayObject,
1313+ SINGLE_USER_PLATFORM_ID} from "../common/infrastructure/Atomic.js";
1314import { SourceType, SourceConfig } from '../common/infrastructure/config/source/sources.js';
1415import { PollingOptions } from "../common/infrastructure/config/common.js";
1516import {
···341342 }
342343 return [false, `${stPrefix} ${EXPECTED_NON_DISCOVERED_REASON}`]
343344 } else {
344344- const discoveredPlays = this.getRecentlyDiscoveredPlaysByPlatform(genGroupId(candidate));
345345+ const discoveredPlays = this.getRecentlyDiscoveredPlaysByPlatform(this.multiPlatform ? genGroupId(candidate) : SINGLE_USER_PLATFORM_ID);
345346 if (discoveredPlays.length === 0 || !playObjDataMatch(discoveredPlays[0], candidate)) {
346347 // if most recent stateful play is not this track we'll add it
347348 return [true,`${stPrefix} added after ${thresholdResultSummary(thresholdResults)}. Matched other recent play but could not determine time frame due to missing duration. Allowed due to not being last played track.`];