1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00
Peertube/server/core/initializers/migrations/0880-video-comment-count.ts
RF9A5V 25a9f37ded
Add Comment Count to Video Preview Components (#6635)
* 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>
2025-04-02 16:29:22 +02:00

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
}