aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-12 11:47:45 +0100
committerChocobozzz <me@florianbigard.com>2018-01-12 11:47:45 +0100
commit32b2b43c06621e384c0bd1610ef0bb9f23399be7 (patch)
treec195943354838bcbe3b1993d77aaf0d3200fd19d /server/initializers
parent6502c3d43e512e968ad49f5a3bc9abc302471e18 (diff)
downloadPeerTube-32b2b43c06621e384c0bd1610ef0bb9f23399be7.tar.gz
PeerTube-32b2b43c06621e384c0bd1610ef0bb9f23399be7.tar.zst
PeerTube-32b2b43c06621e384c0bd1610ef0bb9f23399be7.zip
Update follower/following counts
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0175-actor-follow-counts.ts24
2 files changed, 25 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index eda3403f2..2c64efe1f 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -9,7 +9,7 @@ import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core
9 9
10// --------------------------------------------------------------------------- 10// ---------------------------------------------------------------------------
11 11
12const LAST_MIGRATION_VERSION = 170 12const LAST_MIGRATION_VERSION = 175
13 13
14// --------------------------------------------------------------------------- 14// ---------------------------------------------------------------------------
15 15
diff --git a/server/initializers/migrations/0175-actor-follow-counts.ts b/server/initializers/migrations/0175-actor-follow-counts.ts
new file mode 100644
index 000000000..06ef77b49
--- /dev/null
+++ b/server/initializers/migrations/0175-actor-follow-counts.ts
@@ -0,0 +1,24 @@
1import * as Sequelize from 'sequelize'
2import { ACTOR_FOLLOW_SCORE } from '../index'
3
4async function up (utils: {
5 transaction: Sequelize.Transaction,
6 queryInterface: Sequelize.QueryInterface,
7 sequelize: Sequelize.Sequelize
8}): Promise<void> {
9 const query = 'UPDATE "actor" SET ' +
10 '"followersCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."targetActorId"), ' +
11 '"followingCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."actorId") ' +
12 'WHERE "actor"."serverId" IS NULL'
13
14 await utils.sequelize.query(query)
15}
16
17function down (options) {
18 throw new Error('Not implemented.')
19}
20
21export {
22 up,
23 down
24}