mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Fix:Podcast library stat for total size #2072
This commit is contained in:
		
							parent
							
								
									9553c19b33
								
							
						
					
					
						commit
						1024bc5a75
					
				| @ -469,12 +469,20 @@ module.exports = { | ||||
|    * @returns {Promise<{ totalSize:number, totalDuration:number, numAudioFiles:number, totalItems:number}>} | ||||
|    */ | ||||
|   async getPodcastLibraryStats(libraryId) { | ||||
|     const [statResults] = await Database.sequelize.query(`SELECT SUM(json_extract(pe.audioFile, '$.duration')) AS totalDuration, SUM(li.size) AS totalSize, COUNT(DISTINCT(li.id)) AS totalItems, COUNT(pe.id) AS numAudioFiles FROM libraryItems li, podcasts p LEFT OUTER JOIN podcastEpisodes pe ON pe.podcastId = p.id WHERE p.id = li.mediaId AND li.libraryId = :libraryId;`, { | ||||
|     const [sizeResults] = await Database.sequelize.query(`SELECT SUM(li.size) AS totalSize FROM libraryItems li WHERE li.mediaType = "podcast" AND li.libraryId = :libraryId;`, { | ||||
|       replacements: { | ||||
|         libraryId | ||||
|       } | ||||
|     }) | ||||
|     return statResults[0] | ||||
|     const [statResults] = await Database.sequelize.query(`SELECT SUM(json_extract(pe.audioFile, '$.duration')) AS totalDuration, COUNT(DISTINCT(li.id)) AS totalItems, COUNT(pe.id) AS numAudioFiles FROM libraryItems li, podcasts p LEFT OUTER JOIN podcastEpisodes pe ON pe.podcastId = p.id WHERE p.id = li.mediaId AND li.libraryId = :libraryId;`, { | ||||
|       replacements: { | ||||
|         libraryId | ||||
|       } | ||||
|     }) | ||||
|     return { | ||||
|       ...statResults[0], | ||||
|       totalSize: sizeResults[0].totalSize || 0 | ||||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   /** | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user