mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-26 12:41:29 +02:00
Clear LibraryItemsPodcastFilters count cache after podcast[Episode] is created or destroryed
This commit is contained in:
parent
de5d8650e8
commit
659164003f
@ -1,6 +1,7 @@
|
|||||||
const { DataTypes, Model } = require('sequelize')
|
const { DataTypes, Model } = require('sequelize')
|
||||||
const { getTitlePrefixAtEnd, getTitleIgnorePrefix } = require('../utils')
|
const { getTitlePrefixAtEnd, getTitleIgnorePrefix } = require('../utils')
|
||||||
const Logger = require('../Logger')
|
const Logger = require('../Logger')
|
||||||
|
const libraryItemsPodcastFilters = require('../utils/queries/libraryItemsPodcastFilters')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef PodcastExpandedProperties
|
* @typedef PodcastExpandedProperties
|
||||||
@ -148,6 +149,14 @@ class Podcast extends Model {
|
|||||||
modelName: 'podcast'
|
modelName: 'podcast'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Podcast.addHook('afterDestroy', async (instance) => {
|
||||||
|
libraryItemsPodcastFilters.clearCountCache('podcast', 'afterDestroy')
|
||||||
|
})
|
||||||
|
|
||||||
|
Podcast.addHook('afterCreate', async (instance) => {
|
||||||
|
libraryItemsPodcastFilters.clearCountCache('podcast', 'afterCreate')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasMediaFiles() {
|
get hasMediaFiles() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const { DataTypes, Model } = require('sequelize')
|
const { DataTypes, Model } = require('sequelize')
|
||||||
|
const libraryItemsPodcastFilters = require('../utils/queries/libraryItemsPodcastFilters')
|
||||||
/**
|
/**
|
||||||
* @typedef ChapterObject
|
* @typedef ChapterObject
|
||||||
* @property {number} id
|
* @property {number} id
|
||||||
@ -132,6 +132,14 @@ class PodcastEpisode extends Model {
|
|||||||
onDelete: 'CASCADE'
|
onDelete: 'CASCADE'
|
||||||
})
|
})
|
||||||
PodcastEpisode.belongsTo(podcast)
|
PodcastEpisode.belongsTo(podcast)
|
||||||
|
|
||||||
|
PodcastEpisode.addHook('afterDestroy', async (instance) => {
|
||||||
|
libraryItemsPodcastFilters.clearCountCache('podcastEpisode', 'afterDestroy')
|
||||||
|
})
|
||||||
|
|
||||||
|
PodcastEpisode.addHook('afterCreate', async (instance) => {
|
||||||
|
libraryItemsPodcastFilters.clearCountCache('podcastEpisode', 'afterCreate')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get size() {
|
get size() {
|
||||||
|
@ -100,7 +100,8 @@ module.exports = {
|
|||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
|
|
||||||
clearCountCache() {
|
clearCountCache(model, hook) {
|
||||||
|
Logger.debug(`[LibraryItemsPodcastFilters] ${model}.${hook}: Clearing count cache`)
|
||||||
countCache.clear()
|
countCache.clear()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user