mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Update channel updatedAt when uploading a video
This commit is contained in:
parent
1e0741d165
commit
e024fd6a74
12 changed files with 95 additions and 38 deletions
|
@ -1,8 +1,9 @@
|
|||
import * as retry from 'async/retry'
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { QueryTypes, Transaction } from 'sequelize'
|
||||
import { Model } from 'sequelize-typescript'
|
||||
import { sequelizeTypescript } from '@server/initializers/database'
|
||||
import { logger } from './logger'
|
||||
import { Transaction } from 'sequelize'
|
||||
|
||||
function retryTransactionWrapper <T, A, B, C, D> (
|
||||
functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise<T> | Bluebird<T>,
|
||||
|
@ -96,6 +97,18 @@ function deleteNonExistingModels <T extends { hasSameUniqueKeysThan (other: T):
|
|||
.map(f => f.destroy({ transaction: t }))
|
||||
}
|
||||
|
||||
// Sequelize always skip the update if we only update updatedAt field
|
||||
function setAsUpdated (table: string, id: number, transaction?: Transaction) {
|
||||
return sequelizeTypescript.query(
|
||||
`UPDATE "${table}" SET "updatedAt" = :updatedAt WHERE id = :id`,
|
||||
{
|
||||
replacements: { table, id, updatedAt: new Date() },
|
||||
type: QueryTypes.UPDATE,
|
||||
transaction
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
|
@ -104,5 +117,6 @@ export {
|
|||
transactionRetryer,
|
||||
updateInstanceWithAnother,
|
||||
afterCommitIfTransaction,
|
||||
deleteNonExistingModels
|
||||
deleteNonExistingModels,
|
||||
setAsUpdated
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue