Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
f18a060a
Verified
Commit
f18a060a
authored
May 05, 2022
by
Chocobozzz
Browse files
Remove comments, rates and views from stats
It prevent us to apply date filters
parent
b2d03a83
Changes
5
Hide whitespace changes
Inline
Side-by-side
client/src/app/+stats/video/video-stats.component.ts
View file @
f18a060a
...
...
@@ -137,15 +137,11 @@ export class VideoStatsComponent implements OnInit {
this
.
overallStatCards
=
[
{
label
:
$localize
`Views`
,
value
:
this
.
numberFormatter
.
transform
(
overallStats
.
views
)
},
{
label
:
$localize
`Comments`
,
value
:
this
.
numberFormatter
.
transform
(
overallStats
.
comments
)
value
:
this
.
numberFormatter
.
transform
(
this
.
video
.
views
)
},
{
label
:
$localize
`Likes`
,
value
:
this
.
numberFormatter
.
transform
(
overallStats
.
likes
)
value
:
this
.
numberFormatter
.
transform
(
this
.
video
.
likes
)
},
{
label
:
$localize
`Average watch time`
,
...
...
server/models/view/local-video-viewer.ts
View file @
f18a060a
...
...
@@ -134,9 +134,6 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
FETCH FIRST 1 ROW ONLY`
const
watchPeakPromise
=
LocalVideoViewerModel
.
sequelize
.
query
<
any
>
(
watchPeakQuery
,
options
)
const
commentsQuery
=
`SELECT COUNT(*) AS comments FROM "videoComment" WHERE "videoId" = :videoId`
const
commentsPromise
=
LocalVideoViewerModel
.
sequelize
.
query
<
any
>
(
commentsQuery
,
options
)
const
countriesQuery
=
`SELECT country, COUNT(country) as viewers `
+
`FROM "localVideoViewer" `
+
`WHERE "videoId" = :videoId AND country IS NOT NULL `
+
...
...
@@ -144,10 +141,9 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
`ORDER BY viewers DESC`
const
countriesPromise
=
LocalVideoViewerModel
.
sequelize
.
query
<
any
>
(
countriesQuery
,
options
)
const
[
rowsWatchTime
,
rowsWatchPeak
,
rowsComment
,
rowsCountries
]
=
await
Promise
.
all
([
const
[
rowsWatchTime
,
rowsWatchPeak
,
rowsCountries
]
=
await
Promise
.
all
([
watchTimePromise
,
watchPeakPromise
,
commentsPromise
,
countriesPromise
])
...
...
@@ -166,14 +162,6 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
?
rowsWatchPeak
[
0
].
dateBreakpoint
||
null
:
null
,
views
:
video
.
views
,
likes
:
video
.
likes
,
dislikes
:
video
.
dislikes
,
comments
:
rowsComment
.
length
!==
0
?
parseInt
(
rowsComment
[
0
].
comments
)
||
0
:
0
,
countries
:
rowsCountries
.
map
(
r
=>
({
isoCode
:
r
.
country
,
viewers
:
r
.
viewers
...
...
server/tests/api/views/video-views-overall-stats.ts
View file @
f18a060a
...
...
@@ -17,57 +17,6 @@ describe('Test views overall stats', function () {
servers
=
await
prepareViewsServers
()
})
describe
(
'
Test rates and comments of local videos on VOD
'
,
function
()
{
let
vodVideoId
:
string
before
(
async
function
()
{
this
.
timeout
(
120000
);
({
vodVideoId
}
=
await
prepareViewsVideos
({
servers
,
live
:
false
,
vod
:
true
}))
})
it
(
'
Should have the appropriate likes
'
,
async
function
()
{
this
.
timeout
(
60000
)
await
servers
[
0
].
videos
.
rate
({
id
:
vodVideoId
,
rating
:
'
like
'
})
await
servers
[
1
].
videos
.
rate
({
id
:
vodVideoId
,
rating
:
'
like
'
})
await
waitJobs
(
servers
)
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
vodVideoId
})
expect
(
stats
.
likes
).
to
.
equal
(
2
)
expect
(
stats
.
dislikes
).
to
.
equal
(
0
)
})
it
(
'
Should have the appropriate dislikes
'
,
async
function
()
{
this
.
timeout
(
60000
)
await
servers
[
0
].
videos
.
rate
({
id
:
vodVideoId
,
rating
:
'
dislike
'
})
await
servers
[
1
].
videos
.
rate
({
id
:
vodVideoId
,
rating
:
'
dislike
'
})
await
waitJobs
(
servers
)
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
vodVideoId
})
expect
(
stats
.
likes
).
to
.
equal
(
0
)
expect
(
stats
.
dislikes
).
to
.
equal
(
2
)
})
it
(
'
Should have the appropriate comments
'
,
async
function
()
{
this
.
timeout
(
60000
)
await
servers
[
0
].
comments
.
createThread
({
videoId
:
vodVideoId
,
text
:
'
root
'
})
await
servers
[
0
].
comments
.
addReplyToLastThread
({
text
:
'
reply
'
})
await
servers
[
1
].
comments
.
createThread
({
videoId
:
vodVideoId
,
text
:
'
root
'
})
await
waitJobs
(
servers
)
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
vodVideoId
})
expect
(
stats
.
comments
).
to
.
equal
(
3
)
})
})
describe
(
'
Test watch time stats of local videos on live and VOD
'
,
function
()
{
let
vodVideoId
:
string
let
liveVideoId
:
string
...
...
@@ -82,8 +31,9 @@ describe('Test views overall stats', function () {
it
(
'
Should display overall stats of a video with no viewers
'
,
async
function
()
{
for
(
const
videoId
of
[
liveVideoId
,
vodVideoId
])
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
})
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
videoId
})
expect
(
stats
.
views
).
to
.
equal
(
0
)
expect
(
video
.
views
).
to
.
equal
(
0
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
0
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
0
)
}
...
...
@@ -100,8 +50,9 @@ describe('Test views overall stats', function () {
for
(
const
videoId
of
[
liveVideoId
,
vodVideoId
])
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
})
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
videoId
})
expect
(
stats
.
views
).
to
.
equal
(
0
)
expect
(
video
.
views
).
to
.
equal
(
0
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
1
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
1
)
}
...
...
@@ -118,14 +69,18 @@ describe('Test views overall stats', function () {
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
vodVideoId
})
expect
(
stats
.
views
).
to
.
equal
(
1
)
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
vodVideoId
})
expect
(
video
.
views
).
to
.
equal
(
1
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
2
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
4
)
}
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
liveVideoId
})
expect
(
stats
.
views
).
to
.
equal
(
1
)
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
liveVideoId
})
expect
(
video
.
views
).
to
.
equal
(
1
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
21
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
41
)
}
...
...
@@ -143,16 +98,18 @@ describe('Test views overall stats', function () {
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
vodVideoId
})
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
vodVideoId
})
expect
(
stats
.
views
).
to
.
equal
(
1
)
expect
(
video
.
views
).
to
.
equal
(
1
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
2
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
6
)
}
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
liveVideoId
})
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
liveVideoId
})
expect
(
stats
.
views
).
to
.
equal
(
1
)
expect
(
video
.
views
).
to
.
equal
(
1
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
14
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
43
)
}
...
...
@@ -167,14 +124,18 @@ describe('Test views overall stats', function () {
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
vodVideoId
})
expect
(
stats
.
views
).
to
.
equal
(
2
)
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
vodVideoId
})
expect
(
video
.
views
).
to
.
equal
(
2
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
3
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
11
)
}
{
const
stats
=
await
servers
[
0
].
videoStats
.
getOverallStats
({
videoId
:
liveVideoId
})
expect
(
stats
.
views
).
to
.
equal
(
2
)
const
video
=
await
servers
[
0
].
videos
.
get
({
id
:
liveVideoId
})
expect
(
video
.
views
).
to
.
equal
(
2
)
expect
(
stats
.
averageWatchTime
).
to
.
equal
(
22
)
expect
(
stats
.
totalWatchTime
).
to
.
equal
(
88
)
}
...
...
shared/models/videos/stats/video-stats-overall.model.ts
View file @
f18a060a
...
...
@@ -5,11 +5,6 @@ export interface VideoStatsOverall {
viewersPeak
:
number
viewersPeakDate
:
string
views
:
number
likes
:
number
dislikes
:
number
comments
:
number
countries
:
{
isoCode
:
string
viewers
:
number
...
...
support/doc/api/openapi.yaml
View file @
f18a060a
...
...
@@ -6220,14 +6220,6 @@ components:
viewersPeakDate
:
type
:
string
format
:
date-time
views
:
type
:
number
likes
:
type
:
number
dislikes
:
type
:
number
comments
:
type
:
number
countries
:
type
:
array
items
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment