Added "total views" in the my channels list (#5007)

* Added "total views" in the my channels list

Implements https://github.com/Chocobozzz/PeerTube/issues/4331

* Fix lint

* applied suggested change

* updated openAPI spec for the use "withStats" when getting video channels

* applied code change

* removed GROUP BY in query

* Fixed test
This commit is contained in:
Florian CUNY
2022-05-31 16:01:11 +02:00
committed by GitHub
parent b0185d7351
commit c6f8ca4d65
6 changed files with 41 additions and 1 deletions

View File

@@ -478,6 +478,25 @@ describe('Test video channels', function () {
}
})
it('Should report correct total views count', async function () {
// check if there's the property
{
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
for (const channel of data) {
expect(channel).to.haveOwnProperty('totalViews')
expect(channel.totalViews).to.be.a('number')
}
}
// Check if the totalViews count can be updated
{
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id)
expect(channelWithView.totalViews).to.equal(2)
}
})
it('Should report correct videos count', async function () {
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })