Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
0b0a79b7
Commit
0b0a79b7
authored
4 years ago
by
Samuel GAIST
Committed by
Samuel GAIST
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[statistics][templatetags] Add user accurate computation method
This allows for correct numbers to be shown.
parent
bceddcc4
Loading
Loading
2 merge requests
!386
Fix front page stats
,
!342
Django 3 migration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/statistics/templatetags/statistics_tags.py
+42
-3
42 additions, 3 deletions
beat/web/statistics/templatetags/statistics_tags.py
with
42 additions
and
3 deletions
beat/web/statistics/templatetags/statistics_tags.py
+
42
−
3
View file @
0b0a79b7
...
...
@@ -27,16 +27,55 @@
from
django
import
template
from
django.contrib.auth.models
import
User
from
..views
import
calculate_totals
from
...algorithms.models
import
Algorithm
from
...attestations.models
import
Attestation
from
...backend.models
import
Environment
from
...backend.models
import
Queue
from
...backend.models
import
Worker
from
...databases.models
import
Database
from
...dataformats.models
import
DataFormat
from
...experiments.models
import
Experiment
from
...libraries.models
import
Library
from
...plotters.models
import
Plotter
from
...plotters.models
import
PlotterParameter
from
...reports.models
import
Report
from
...search.models
import
Search
from
...team.models
import
Team
from
...toolchains.models
import
Toolchain
register
=
template
.
Library
()
def
calculate_totals
(
user
):
"""
Caculates all totals required by the statistics display
"""
return
dict
(
users
=
User
.
objects
.
count
(),
databases
=
Database
.
objects
.
for_user
(
user
,
True
).
count
(),
environments
=
Environment
.
objects
.
for_user
(
user
,
True
).
count
(),
queues
=
Queue
.
objects
.
count
(),
workers
=
Worker
.
objects
.
count
(),
experiments
=
Experiment
.
objects
.
for_user
(
user
,
True
).
count
(),
toolchains
=
Toolchain
.
objects
.
for_user
(
user
,
True
).
count
(),
algorithms
=
Algorithm
.
objects
.
for_user
(
user
,
True
).
count
(),
libraries
=
Library
.
objects
.
for_user
(
user
,
True
).
count
(),
dataformats
=
DataFormat
.
objects
.
for_user
(
user
,
True
).
count
(),
teams
=
Team
.
objects
.
for_user
(
user
,
True
).
count
(),
attestations
=
Attestation
.
objects
.
for_user
(
user
,
True
).
count
(),
searches
=
Search
.
objects
.
for_user
(
user
,
True
).
count
(),
reports
=
Report
.
objects
.
for_user
(
user
,
True
).
count
(),
plotters
=
Plotter
.
objects
.
for_user
(
user
,
True
).
count
(),
plotterparameters
=
PlotterParameter
.
objects
.
for_user
(
user
,
True
).
count
(),
)
@register.inclusion_tag
(
"
statistics/panels/status.html
"
,
takes_context
=
True
)
def
status
(
context
,
id
):
request
=
context
[
"
request
"
]
return
{
"
request
"
:
context
[
"
request
"
]
,
"
user
"
:
request
.
user
,
"
panel_id
"
:
id
,
"
totals
"
:
calculate_totals
(),
"
totals
"
:
calculate_totals
(
request
.
user
),
}
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