mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Add more logging, clean up typo
This commit is contained in:
		
							parent
							
								
									836d772cd4
								
							
						
					
					
						commit
						691ed88096
					
				| @ -67,6 +67,7 @@ async function up({ context: { queryInterface, logger } }) { | ||||
| 
 | ||||
|     // Iterate over the duplicate book IDs if there is at least one and only keep the first row that has this bookId and seriesId
 | ||||
|     for (const { bookId } of duplicateBookIds) { | ||||
|       logger.info(`[2.13.5 migration] Deduplicating bookId ${bookId} in series "${duplicate.name}" of library ${duplicate.libraryId}`) | ||||
|       // Get all rows of `BookSeries` table that have the same `bookId` and `seriesId`. Sort by `sequence` with nulls sorted last
 | ||||
|       const [duplicateBookSeries] = await queryInterface.sequelize.query( | ||||
|         ` | ||||
| @ -106,6 +107,7 @@ async function up({ context: { queryInterface, logger } }) { | ||||
|           } | ||||
|         ) | ||||
|       } | ||||
|       logger.info(`[2.13.5 migration] Finished cleanup of bookId ${bookId} in series "${duplicate.name}" of library ${duplicate.libraryId}`) | ||||
|     } | ||||
| 
 | ||||
|     // Get all the most recent series which matches the `name` and `libraryId`
 | ||||
|  | ||||
| @ -211,13 +211,15 @@ describe('migration-v2.13.5-series-column-unique', () => { | ||||
| 
 | ||||
|       await up({ context: { queryInterface, logger: Logger } }) | ||||
| 
 | ||||
|       expect(loggerInfoStub.callCount).to.equal(6) | ||||
|       expect(loggerInfoStub.callCount).to.equal(8) | ||||
|       expect(loggerInfoStub.getCall(0).calledWith(sinon.match('UPGRADE BEGIN: 2.13.5-series-column-unique '))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(1).calledWith(sinon.match('[2.13.5 migration] Found 1 duplicate series'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(2).calledWith(sinon.match('[2.13.5 migration] Deduplicating series "Series 1" in library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(3).calledWith(sinon.match('[2.13.5 migration] Deduplication complete'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(4).calledWith(sinon.match('Added unique index on Series.name and Series.libraryId')).to.be.true) | ||||
|       expect(loggerInfoStub.getCall(5).calledWith(sinon.match('UPGRADE END: 2.13.5-series-column-unique '))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(3).calledWith(sinon.match('[2.13.5 migration] Deduplicating bookId 4a38b6e5-0ae4-4de4-b119-4e33891bd63f in series "Series 1" of library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(4).calledWith(sinon.match('[2.13.5 migration] Finished cleanup of bookId 4a38b6e5-0ae4-4de4-b119-4e33891bd63f in series "Series 1" of library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(5).calledWith(sinon.match('[2.13.5 migration] Deduplication complete'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(6).calledWith(sinon.match('Added unique index on Series.name and Series.libraryId'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(7).calledWith(sinon.match('UPGRADE END: 2.13.5-series-column-unique '))).to.be.true | ||||
|       // validate rows
 | ||||
|       const series = await queryInterface.sequelize.query('SELECT "id", "name", "libraryId" FROM Series', { type: queryInterface.sequelize.QueryTypes.SELECT }) | ||||
|       expect(series).to.have.length(1) | ||||
| @ -240,13 +242,15 @@ describe('migration-v2.13.5-series-column-unique', () => { | ||||
| 
 | ||||
|       await up({ context: { queryInterface, logger: Logger } }) | ||||
| 
 | ||||
|       expect(loggerInfoStub.callCount).to.equal(6) | ||||
|       expect(loggerInfoStub.callCount).to.equal(8) | ||||
|       expect(loggerInfoStub.getCall(0).calledWith(sinon.match('UPGRADE BEGIN: 2.13.5-series-column-unique '))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(1).calledWith(sinon.match('[2.13.5 migration] Found 1 duplicate series'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(2).calledWith(sinon.match('[2.13.5 migration] Deduplicating series "Series 1" in library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(3).calledWith(sinon.match('[2.13.5 migration] Deduplication complete'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(4).calledWith(sinon.match('Added unique index on Series.name and Series.libraryId')).to.be.true) | ||||
|       expect(loggerInfoStub.getCall(5).calledWith(sinon.match('UPGRADE END: 2.13.5-series-column-unique '))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(3).calledWith(sinon.match('[2.13.5 migration] Deduplicating bookId 4a38b6e5-0ae4-4de4-b119-4e33891bd63f in series "Series 1" of library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(4).calledWith(sinon.match('[2.13.5 migration] Finished cleanup of bookId 4a38b6e5-0ae4-4de4-b119-4e33891bd63f in series "Series 1" of library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(5).calledWith(sinon.match('[2.13.5 migration] Deduplication complete'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(6).calledWith(sinon.match('Added unique index on Series.name and Series.libraryId'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(7).calledWith(sinon.match('UPGRADE END: 2.13.5-series-column-unique '))).to.be.true | ||||
|       // validate rows
 | ||||
|       const series = await queryInterface.sequelize.query('SELECT "id", "name", "libraryId" FROM Series', { type: queryInterface.sequelize.QueryTypes.SELECT }) | ||||
|       expect(series).to.have.length(1) | ||||
| @ -263,26 +267,28 @@ describe('migration-v2.13.5-series-column-unique', () => { | ||||
|       ]) | ||||
|       // Create a book that is in both series
 | ||||
|       await queryInterface.bulkInsert('BookSeries', [ | ||||
|         { id: bookSeries1Id, sequence: '1', bookId: book1Id, seriesId: series1Id }, | ||||
|         { id: bookSeries1Id, sequence: '3', bookId: book1Id, seriesId: series1Id }, | ||||
|         { id: bookSeries2Id, sequence: '2', bookId: book1Id, seriesId: series2Id } | ||||
|       ]) | ||||
| 
 | ||||
|       await up({ context: { queryInterface, logger: Logger } }) | ||||
| 
 | ||||
|       expect(loggerInfoStub.callCount).to.equal(6) | ||||
|       expect(loggerInfoStub.callCount).to.equal(8) | ||||
|       expect(loggerInfoStub.getCall(0).calledWith(sinon.match('UPGRADE BEGIN: 2.13.5-series-column-unique '))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(1).calledWith(sinon.match('[2.13.5 migration] Found 1 duplicate series'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(2).calledWith(sinon.match('[2.13.5 migration] Deduplicating series "Series 1" in library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(3).calledWith(sinon.match('[2.13.5 migration] Deduplication complete'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(4).calledWith(sinon.match('Added unique index on Series.name and Series.libraryId')).to.be.true) | ||||
|       expect(loggerInfoStub.getCall(5).calledWith(sinon.match('UPGRADE END: 2.13.5-series-column-unique '))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(3).calledWith(sinon.match('[2.13.5 migration] Deduplicating bookId 8bc2e61d-47f6-42ef-a3f4-93cf2f1de82f in series "Series 1" of library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(4).calledWith(sinon.match('[2.13.5 migration] Finished cleanup of bookId 8bc2e61d-47f6-42ef-a3f4-93cf2f1de82f in series "Series 1" of library 3a5a1c7c-a914-472e-88b0-b871ceae63e7'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(5).calledWith(sinon.match('[2.13.5 migration] Deduplication complete'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(6).calledWith(sinon.match('Added unique index on Series.name and Series.libraryId'))).to.be.true | ||||
|       expect(loggerInfoStub.getCall(7).calledWith(sinon.match('UPGRADE END: 2.13.5-series-column-unique '))).to.be.true | ||||
|       // validate rows
 | ||||
|       const series = await queryInterface.sequelize.query('SELECT "id", "name", "libraryId" FROM Series', { type: queryInterface.sequelize.QueryTypes.SELECT }) | ||||
|       expect(series).to.have.length(1) | ||||
|       expect(series).to.deep.include({ id: series1Id, name: 'Series 1', libraryId: library1Id }) | ||||
|       const bookSeries = await queryInterface.sequelize.query('SELECT "id", "sequence", "bookId", "seriesId" FROM BookSeries', { type: queryInterface.sequelize.QueryTypes.SELECT }) | ||||
|       expect(bookSeries).to.have.length(1) | ||||
|       expect(bookSeries).to.deep.include({ id: bookSeries1Id, sequence: '1, 2', bookId: book1Id, seriesId: series1Id }) | ||||
|       expect(bookSeries).to.deep.include({ id: bookSeries1Id, sequence: '2', bookId: book1Id, seriesId: series1Id }) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user