Increase history pageSize from 100 to 500 to fetch more records
Fixes issue where series beyond position 100 in history were not appearing in recently completed section.
This commit is contained in:
@@ -251,8 +251,6 @@ router.get('/recent', requireAuth, async (req, res) => {
|
|||||||
showAll ? getEmbyUsers() : Promise.resolve(new Map())
|
showAll ? getEmbyUsers() : Promise.resolve(new Map())
|
||||||
]);
|
]);
|
||||||
|
|
||||||
console.log(`[History] Fetched ${sonarrHistory.length} Sonarr records, ${radarrHistory.length} Radarr records since ${since.toISOString()}`);
|
|
||||||
|
|
||||||
// Build tag maps from the cached poll data where available,
|
// Build tag maps from the cached poll data where available,
|
||||||
// falling back to what's embedded in history records
|
// falling back to what's embedded in history records
|
||||||
const sonarrTagsData = cache.get('poll:sonarr-tags') || [];
|
const sonarrTagsData = cache.get('poll:sonarr-tags') || [];
|
||||||
@@ -260,37 +258,22 @@ router.get('/recent', requireAuth, async (req, res) => {
|
|||||||
const sonarrTagMap = new Map(sonarrTagsData.flatMap(t => t.data || []).map(t => [t.id, t.label]));
|
const sonarrTagMap = new Map(sonarrTagsData.flatMap(t => t.data || []).map(t => [t.id, t.label]));
|
||||||
const radarrTagMap = new Map(radarrTagsData.map(t => [t.id, t.label]));
|
const radarrTagMap = new Map(radarrTagsData.map(t => [t.id, t.label]));
|
||||||
|
|
||||||
console.log(`[History] Tag maps - sonarr: ${sonarrTagMap.size} tags, radarr: ${radarrTagMap.size} tags`);
|
|
||||||
|
|
||||||
const historyItems = [];
|
const historyItems = [];
|
||||||
|
|
||||||
// --- Sonarr history ---
|
// --- Sonarr history ---
|
||||||
for (const record of sonarrHistory) {
|
for (const record of sonarrHistory) {
|
||||||
try {
|
try {
|
||||||
const outcome = classifySonarrEvent(record.eventType);
|
const outcome = classifySonarrEvent(record.eventType);
|
||||||
if (outcome === 'other') {
|
if (outcome === 'other') continue;
|
||||||
console.log(`[History] Filtered out Sonarr record with eventType: ${record.eventType}, sourceTitle: ${record.sourceTitle || record.title || 'unknown'}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const series = record.series;
|
const series = record.series;
|
||||||
if (!series) {
|
if (!series) continue;
|
||||||
console.log(`[History] Filtered out Sonarr record with no series object - eventType: ${record.eventType}, sourceTitle: ${record.sourceTitle || record.title || 'unknown'}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rawTagIds = series.tags || [];
|
|
||||||
const allTags = extractAllTags(series.tags, sonarrTagMap);
|
const allTags = extractAllTags(series.tags, sonarrTagMap);
|
||||||
const matchedUserTag = extractUserTag(series.tags, sonarrTagMap, username);
|
const matchedUserTag = extractUserTag(series.tags, sonarrTagMap, username);
|
||||||
const hasAnyTag = allTags.length > 0;
|
const hasAnyTag = allTags.length > 0;
|
||||||
|
|
||||||
// Log all series to see what's coming through
|
if (!(showAll ? hasAnyTag : !!matchedUserTag)) continue;
|
||||||
console.log(`[History] Series: "${series.title}" - raw tag IDs: [${rawTagIds.join(', ') || 'none'}], resolved tags: [${allTags.join(', ') || 'none'}], matchedUserTag: ${matchedUserTag || 'none'}`);
|
|
||||||
|
|
||||||
if (!(showAll ? hasAnyTag : !!matchedUserTag)) {
|
|
||||||
console.log(`[History] Filtered out series "${series.title}" - tags: [${allTags.join(', ') || 'none'}], matchedUserTag: ${matchedUserTag || 'none'}, username: ${username}, showAll: ${showAll}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const quality = record.quality && record.quality.quality && record.quality.quality.name
|
const quality = record.quality && record.quality.quality && record.quality.quality.name
|
||||||
? record.quality.quality.name
|
? record.quality.quality.name
|
||||||
@@ -331,28 +314,16 @@ router.get('/recent', requireAuth, async (req, res) => {
|
|||||||
for (const record of radarrHistory) {
|
for (const record of radarrHistory) {
|
||||||
try {
|
try {
|
||||||
const outcome = classifyRadarrEvent(record.eventType);
|
const outcome = classifyRadarrEvent(record.eventType);
|
||||||
if (outcome === 'other') {
|
if (outcome === 'other') continue;
|
||||||
console.log(`[History] Filtered out Radarr record with eventType: ${record.eventType}, sourceTitle: ${record.sourceTitle || record.title || 'unknown'}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const movie = record.movie;
|
const movie = record.movie;
|
||||||
if (!movie) {
|
if (!movie) continue;
|
||||||
console.log(`[History] Filtered out Radarr record with no movie object - eventType: ${record.eventType}, sourceTitle: ${record.sourceTitle || record.title || 'unknown'}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const rawTagIds = movie.tags || [];
|
|
||||||
const allTags = extractAllTags(movie.tags, radarrTagMap);
|
const allTags = extractAllTags(movie.tags, radarrTagMap);
|
||||||
const matchedUserTag = extractUserTag(movie.tags, radarrTagMap, username);
|
const matchedUserTag = extractUserTag(movie.tags, radarrTagMap, username);
|
||||||
const hasAnyTag = allTags.length > 0;
|
const hasAnyTag = allTags.length > 0;
|
||||||
|
|
||||||
// Log all movies to see what's coming through
|
if (!(showAll ? hasAnyTag : !!matchedUserTag)) continue;
|
||||||
console.log(`[History] Movie: "${movie.title}" - raw tag IDs: [${rawTagIds.join(', ') || 'none'}], resolved tags: [${allTags.join(', ') || 'none'}], matchedUserTag: ${matchedUserTag || 'none'}`);
|
|
||||||
|
|
||||||
if (!(showAll ? hasAnyTag : !!matchedUserTag)) {
|
|
||||||
console.log(`[History] Filtered out movie "${movie.title}" - tags: [${allTags.join(', ') || 'none'}], matchedUserTag: ${matchedUserTag || 'none'}, username: ${username}, showAll: ${showAll}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const quality = record.quality && record.quality.quality && record.quality.quality.name
|
const quality = record.quality && record.quality.quality && record.quality.quality.name
|
||||||
? record.quality.quality.name
|
? record.quality.quality.name
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ async function fetchSonarrHistory(since) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await retriever.getHistory({
|
const response = await retriever.getHistory({
|
||||||
pageSize: 100,
|
pageSize: 500,
|
||||||
sortKey: 'date',
|
sortKey: 'date',
|
||||||
sortDir: 'descending',
|
sortDir: 'descending',
|
||||||
includeSeries: true,
|
includeSeries: true,
|
||||||
@@ -87,7 +87,7 @@ async function fetchRadarrHistory(since) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await retriever.getHistory({
|
const response = await retriever.getHistory({
|
||||||
pageSize: 100,
|
pageSize: 500,
|
||||||
sortKey: 'date',
|
sortKey: 'date',
|
||||||
sortDir: 'descending',
|
sortDir: 'descending',
|
||||||
includeMovie: true,
|
includeMovie: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user