Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
videoag
backend
Commits
e8ed9302
Commit
e8ed9302
authored
1 month ago
by
Simon Künzel
Browse files
Options
Downloads
Patches
Plain Diff
Fix stats requests
parent
253f41d8
No related branches found
No related tags found
No related merge requests found
Pipeline
#7626
passed
1 month ago
Stage: build
Stage: run
Pipeline: backend
#7627
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/src/api/routes/stats.py
+5
-2
5 additions, 2 deletions
api/src/api/routes/stats.py
with
5 additions
and
2 deletions
api/src/api/routes/stats.py
+
5
−
2
View file @
e8ed9302
import
math
import
re
from
datetime
import
timedelta
import
more_itertools
from
typing
import
Sequence
...
...
@@ -179,7 +180,7 @@ def api_route_get_publish_medium_stats(publish_medium_id: int):
segment_total_views_json
=
[]
segment_unique_views_json
=
[]
segment_duration_sec
=
None
segment_duration_sec
=
5
if
len
(
segments
)
>
0
:
if
generic_lecture_stats
is
None
:
raise
Exception
(
"
Some segments exist but no generic lecture stats exist (which store segment duration)
"
)
...
...
@@ -205,7 +206,7 @@ def api_route_get_publish_medium_stats(publish_medium_id: int):
for
type
in
ClientStatType
}
for
stat
in
client_stats
:
client_stats_json
[
stat
.
type
][
stat
.
value
]
=
stat
.
client_count
client_stats_json
[
stat
.
type
.
value
][
stat
.
value
]
=
stat
.
client_count
return
{
"
view_count
"
:
generic_medium_stats
.
view_count
if
generic_medium_stats
else
0
,
...
...
@@ -280,6 +281,8 @@ def api_route_get_lecture_stats(lecture_id: int):
daily_views_counts_json
.
append
(
view_count
)
daily_views_dates_json
.
append
(
current_date
.
strftime
(
"
%d.%m.%Y
"
))
current_date
+=
timedelta
(
days
=
1
)
return
{
"
view_count
"
:
generic_lecture_stats
.
view_count
if
generic_lecture_stats
else
0
,
"
total_watched_seconds
"
:
generic_lecture_stats
.
total_watched_seconds
if
generic_lecture_stats
else
0
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment