<div i18n class="video-channel-followers">{videoChannel.followersCount, plural, =1 {1 subscriber} other {{{ videoChannel.followersCount }} subscribers}}</div>
+ <div i18n class="video-channel-videos">{videoChannel.videosCount, plural, =0 {No videos} =1 {1 video} other {{{ videoChannel.videosCount }} videos}}</div>
+
<div class="video-channel-buttons">
<my-edit-button [routerLink]="[ 'update', videoChannel.nameWithHost ]"></my-edit-button>
<my-delete-button (click)="deleteVideoChannel(videoChannel)"></my-delete-button>
const res = await this.confirmService.confirmWithInput(
this.i18n(
// tslint:disable
- 'Do you really want to delete {{channelDisplayName}}? It will delete all videos uploaded in this channel, and you will not be able to create another channel with the same name ({{channelName}})!',
- { channelDisplayName: videoChannel.displayName, channelName: videoChannel.name }
+ 'Do you really want to delete {{channelDisplayName}}? It will delete {{videosCount}} videos uploaded in this channel, and you will not be able to create another channel with the same name ({{channelName}})!',
+ { channelDisplayName: videoChannel.displayName, videosCount: videoChannel.videosCount, channelName: videoChannel.name }
),
this.i18n(
'Please type the display name of the video channel ({{displayName}}) to confirm',
@import '_variables';
@import '_mixins';
+.modal-body {
+ font-size: 15px;
+}
+
.button {
padding: 0 13px;
}
isLocal: boolean
nameWithHost: string
nameWithHostForced: string
+
ownerAccount?: Account
ownerBy?: string
ownerAvatarUrl?: string
+
+ videosCount?: number
+
viewsPerDay?: ViewsPerDate[]
constructor (hash: ServerVideoChannel) {
this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
+ this.videosCount = hash.videosCount
+
if (hash.viewsPerDay) {
this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) }))
}
return {
attributes: {
include: [
+ [
+ literal('(SELECT COUNT(*) FROM "video" WHERE "channelId" = "VideoChannelModel"."id")'),
+ 'videosCount'
+ ],
[
literal(
'(' +
}
toFormattedJSON (this: MChannelFormattable): VideoChannel {
- const viewsPerDay = this.get('viewsPerDay') as string
+ const viewsPerDayString = this.get('viewsPerDay') as string
+ const videosCount = this.get('videosCount') as number
+
+ let viewsPerDay: { date: Date, views: number }[]
+
+ if (viewsPerDayString) {
+ viewsPerDay = viewsPerDayString.split(',')
+ .map(v => {
+ const [ dateString, amount ] = v.split('|')
+
+ return {
+ date: new Date(dateString),
+ views: +amount
+ }
+ })
+ }
const actor = this.Actor.toFormattedJSON()
const videoChannel = {
createdAt: this.createdAt,
updatedAt: this.updatedAt,
ownerAccount: undefined,
- viewsPerDay: viewsPerDay
- ? viewsPerDay.split(',').map(v => {
- const o = v.split('|')
- return {
- date: new Date(o[0]),
- views: +o[1]
- }
- })
- : undefined
+ videosCount,
+ viewsPerDay
}
if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON()
@AllowNull(false)
@Is('VideoPrivacy', value => throwIfNotValid(value, isVideoPrivacyValid, 'privacy'))
@Column
- privacy: number
+ privacy: VideoPrivacy
@AllowNull(false)
@Is('VideoNSFW', value => throwIfNotValid(value, isBooleanValid, 'NSFW boolean'))
}
})
- it('Should report correct channel statistics', async function () {
+ it('Should report correct channel views per days', async function () {
this.timeout(10000)
{
accountName: userInfo.account.name + '@' + userInfo.account.host,
withStats: true
})
- res.body.data.forEach((channel: VideoChannel) => {
+
+ const channels: VideoChannel[] = res.body.data
+
+ for (const channel of channels) {
expect(channel).to.haveOwnProperty('viewsPerDay')
expect(channel.viewsPerDay).to.have.length(30 + 1) // daysPrior + today
- channel.viewsPerDay.forEach((v: ViewsPerDate) => {
+
+ for (const v of channel.viewsPerDay) {
expect(v.date).to.be.an('string')
expect(v.views).to.equal(0)
- })
- })
+ }
+ }
}
{
}
})
+ it('Should report correct videos count', async function () {
+ const res = await getAccountVideoChannelsList({
+ url: servers[0].url,
+ accountName: userInfo.account.name + '@' + userInfo.account.host,
+ withStats: true
+ })
+ const channels: VideoChannel[] = res.body.data
+
+ const totoChannel = channels.find(c => c.name === 'toto_channel')
+ const rootChannel = channels.find(c => c.name === 'root_channel')
+
+ expect(rootChannel.videosCount).to.equal(1)
+ expect(totoChannel.videosCount).to.equal(0)
+ })
+
after(async function () {
await cleanupTests(servers)
})
support: string
isLocal: boolean
ownerAccount?: Account
+
+ videosCount?: number
viewsPerDay?: ViewsPerDate[] // chronologically ordered
}