min: Math.max(0, this.videoChannelsMinimumDailyViews - (3 * this.videoChannelsMaximumDailyViews / 100)),
max: this.videoChannelsMaximumDailyViews
}
- }],
+ }]
},
layout: {
padding: {
}
},
elements: {
- point:{
+ point: {
radius: 0
}
},
mode: 'index',
intersect: false,
custom: function (tooltip: any) {
- if (!tooltip) return;
- // disable displaying the color box;
- tooltip.displayColors = false;
+ if (!tooltip) return
+ // disable displaying the color box
+ tooltip.displayColors = false
},
callbacks: {
- label: function (tooltip: any, data: any) {
- return `${tooltip.value} views`;
- }
+ label: (tooltip: any, data: any) => `${tooltip.value} views`
}
},
hover: {
private loadVideoChannels () {
this.authService.userInformationLoaded
- .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account)))
+ .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true)))
.subscribe(res => {
this.videoChannels = res.data
this.videoChannelsData = this.videoChannels.map(v => ({
this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
if (hash.viewsPerDay) {
- this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date)}))
+ this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) }))
}
if (hash.ownerAccount) {
)
}
- listAccountVideoChannels (account: Account, componentPagination?: ComponentPaginationLight): Observable<ResultList<VideoChannel>> {
+ listAccountVideoChannels (
+ account: Account,
+ componentPagination?: ComponentPaginationLight,
+ withStats = false
+ ): Observable<ResultList<VideoChannel>> {
const pagination = componentPagination
? this.restService.componentPaginationToRestPagination(componentPagination)
: { start: 0, count: 20 }
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination)
+ params = params.set('withStats', withStats + '')
const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels'
return this.authHttp.get<ResultList<VideoChannelServer>>(url, { params })
accountsSortValidator,
ensureAuthUserOwnsAccountValidator,
videoChannelsSortValidator,
- videosSortValidator
+ videosSortValidator,
+ videoChannelStatsValidator
} from '../../middlewares/validators'
import { AccountModel } from '../../models/account/account'
import { AccountVideoRateModel } from '../../models/account/account-video-rate'
accountsRouter.get('/:accountName/video-channels',
asyncMiddleware(accountNameWithHostGetValidator),
+ videoChannelStatsValidator,
paginationValidator,
videoChannelsSortValidator,
setDefaultSort,
accountId: res.locals.account.id,
start: req.query.start,
count: req.query.count,
- sort: req.query.sort
+ sort: req.query.sort,
+ withStats: req.query.withStats
}
const resultList = await VideoChannelModel.listByAccount(options)
import * as express from 'express'
-import { body, param } from 'express-validator'
+import { body, param, query } from 'express-validator'
import { UserRight } from '../../../../shared'
import {
isVideoChannelDescriptionValid,
}
]
+const videoChannelStatsValidator = [
+ query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'),
+
+ (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ if (areValidationErrors(req, res)) return
+ return next()
+ }
+]
+
// ---------------------------------------------------------------------------
export {
videoChannelsUpdateValidator,
videoChannelsRemoveValidator,
videoChannelsNameWithHostValidator,
- localVideoChannelValidator
+ localVideoChannelValidator,
+ videoChannelStatsValidator
}
// ---------------------------------------------------------------------------
const scopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR ]
- options.withStats = true // TODO: remove beyond after initial tests
if (options.withStats) {
scopes.push({
method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ]