No segundo if
, essa substração:
totalContents.rows[0].count - totalContentsBeforeTabcoins.rows.length
Acaba retornando a quantidade de conteúdos que foram criados depois da feature de TabCoins. Então talvez precise ficar assim:
} else if (
totalContentsBeforeTabcoins.rows.length !==
(totalUsersTabcoinsAfter.rows[0].sum - totalUsersTabcoinsBefore.rows[0].sum) / 10
) {
throw new UnprocessableEntityError({
message: 'Number of added User TabCoins does not match',
context: {
totalContentsBeforeTabcoins: totalContentsBeforeTabcoins.rows.length,
totalUsersTabcoinsBefore: totalUsersTabcoinsBefore.rows[0].sum,
totalUsersTabcoinsAfter: totalUsersTabcoinsAfter.rows[0].sum,
},
O que acha?