1
0
Fork 0
This commit is contained in:
Chocobozzz 2018-01-12 12:18:11 +01:00
parent a3fd560d11
commit 38768a367b
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 6 additions and 8 deletions

View file

@ -1,5 +1,4 @@
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { ACTOR_FOLLOW_SCORE } from '../index'
async function up (utils: { async function up (utils: {
transaction: Sequelize.Transaction, transaction: Sequelize.Transaction,

View file

@ -2,9 +2,8 @@ import * as Bluebird from 'bluebird'
import { values } from 'lodash' import { values } from 'lodash'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { import {
AfterCreate, AfterDestroy, AfterUpdate, AfterCreate, AfterDestroy, AfterUpdate, AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, IsInt, Max, Model,
AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, IsInt, Max, Model, Table, Table, UpdatedAt
UpdatedAt
} from 'sequelize-typescript' } from 'sequelize-typescript'
import { FollowState } from '../../../shared/models/actors' import { FollowState } from '../../../shared/models/actors'
import { AccountFollow } from '../../../shared/models/actors/follow.model' import { AccountFollow } from '../../../shared/models/actors/follow.model'
@ -83,7 +82,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
@AfterCreate @AfterCreate
@AfterUpdate @AfterUpdate
static incrementFollowerAndFollowingCount (instance: ActorFollowModel) { static incrementFollowerAndFollowingCount (instance: ActorFollowModel) {
if (instance.state !== 'accepted') return if (instance.state !== 'accepted') return undefined
return Promise.all([ return Promise.all([
ActorModel.incrementFollows(instance.actorId, 'followingCount', 1), ActorModel.incrementFollows(instance.actorId, 'followingCount', 1),

View file

@ -117,7 +117,7 @@ describe('Test follows', function () {
expect(follows.length).to.equal(0) expect(follows.length).to.equal(0)
}) })
it('Should have the correct following counts', async function () { it('Should have the correct follows counts', async function () {
await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2)
await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0)
@ -158,7 +158,7 @@ describe('Test follows', function () {
expect(follows.length).to.equal(0) expect(follows.length).to.equal(0)
}) })
it('Should have the correct following counts 2', async function () { it('Should have the correct follows counts 2', async function () {
await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1) await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1)
await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
@ -248,7 +248,7 @@ describe('Test follows', function () {
await wait(7000) await wait(7000)
}) })
it('Should have the correct following counts 2', async function () { it('Should have the correct follows counts 3', async function () {
await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2)
await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0)