mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00

* WIP: Add backend functionality to store comment count per video and update on comment visibility actions * WIP: Display image icon and comment count on video miniature component * Probably don't need to index the comment count * Added comment count back to mini video component * Added basic tests * Sort by comments, more robust comments count --------- Co-authored-by: Chocobozzz <me@florianbigard.com>
31 lines
702 B
TypeScript
31 lines
702 B
TypeScript
import * as Sequelize from 'sequelize'
|
|
|
|
async function up (utils: {
|
|
transaction: Sequelize.Transaction
|
|
queryInterface: Sequelize.QueryInterface
|
|
sequelize: Sequelize.Sequelize
|
|
}): Promise<void> {
|
|
const { transaction } = utils
|
|
|
|
{
|
|
await utils.queryInterface.addColumn('video', 'comments', {
|
|
type: Sequelize.INTEGER,
|
|
defaultValue: 0,
|
|
allowNull: false
|
|
}, { transaction })
|
|
}
|
|
|
|
{
|
|
const query = 'UPDATE "video" SET "comments" = (SELECT COUNT(*) FROM "videoComment" WHERE "videoComment"."videoId" = "video"."id")'
|
|
await utils.sequelize.query(query, { transaction })
|
|
}
|
|
}
|
|
|
|
function down (options) {
|
|
throw new Error('Not implemented.')
|
|
}
|
|
|
|
export {
|
|
down,
|
|
up
|
|
}
|