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
e0bb3a2f
Commit
e0bb3a2f
authored
4 years ago
by
Samuel GAIST
Committed by
Flavio TARSETTI
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[search][management][commands] Pre-commit cleanup
parent
6efb94ac
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/search/management/commands/update_leaderboards.py
+36
-27
36 additions, 27 deletions
beat/web/search/management/commands/update_leaderboards.py
with
36 additions
and
27 deletions
beat/web/search/management/commands/update_leaderboards.py
+
36
−
27
View file @
e0bb3a2f
...
...
@@ -28,32 +28,33 @@
import
logging
logger
=
logging
.
getLogger
(
__name__
)
from
django.core.management.base
import
BaseCommand
from
django.core.mail
import
EmailMessage
from
django.template.loader
import
render_to_string
from
django.conf
import
settings
from
django.contrib.sites.models
import
Site
from
django.core.mail
import
EmailMessage
from
django.core.management.base
import
BaseCommand
from
django.template.loader
import
render_to_string
from
...models
import
Leaderboard
from
....
import
__version__
from
...models
import
Leaderboard
logger
=
logging
.
getLogger
(
__name__
)
import
sys
import
datetime
class
Command
(
BaseCommand
):
help
=
'
Update and (optionally) notify owners on leaderboard changes
'
help
=
"
Update and (optionally) notify owners on leaderboard changes
"
def
handle
(
self
,
*
ignored
,
**
arguments
):
# Setup this command's logging level
global
logger
arguments
[
'
verbosity
'
]
=
int
(
arguments
[
'
verbosity
'
])
if
arguments
[
'
verbosity
'
]
>=
1
:
if
arguments
[
'
verbosity
'
]
==
1
:
logger
.
setLevel
(
logging
.
INFO
)
elif
arguments
[
'
verbosity
'
]
>=
2
:
logger
.
setLevel
(
logging
.
DEBUG
)
arguments
[
"
verbosity
"
]
=
int
(
arguments
[
"
verbosity
"
])
if
arguments
[
"
verbosity
"
]
>=
1
:
if
arguments
[
"
verbosity
"
]
==
1
:
logger
.
setLevel
(
logging
.
INFO
)
elif
arguments
[
"
verbosity
"
]
>=
2
:
logger
.
setLevel
(
logging
.
DEBUG
)
objects_updated
=
0
objects_changed
=
0
...
...
@@ -61,28 +62,32 @@ class Command(BaseCommand):
for
obj
in
Leaderboard
.
objects
.
all
():
prev_date
=
obj
.
updated
logger
.
info
(
'
Updating leaderboard for search %s...
'
%
obj
.
search
)
logger
.
info
(
"
Updating leaderboard for search %s...
"
%
obj
.
search
)
changed
=
obj
.
update_experiments
()
objects_updated
+=
1
emails
=
obj
.
notify
.
values_list
(
'
email
'
,
flat
=
True
)
emails
=
obj
.
notify
.
values_list
(
"
email
"
,
flat
=
True
)
# compare tables and notify if required
if
changed
and
emails
:
logger
.
info
(
'
Notifying interested parties for %s
'
%
obj
.
search
)
logger
.
info
(
"
Notifying interested parties for %s
"
%
obj
.
search
)
objects_changed
+=
1
current_site
=
Site
.
objects
.
get_current
()
template_path
=
'
search/leaderboard_changed.txt
'
subject
=
"
Experiment ranking for leaderboard
\"
%s
\"
changed
"
%
obj
.
search
.
fullname
()
template_path
=
"
search/leaderboard_changed.txt
"
subject
=
(
'
Experiment ranking for leaderboard
"
%s
"
changed
'
%
obj
.
search
.
fullname
()
)
mesg
=
EmailMessage
(
subject
.
strip
(),
render_to_string
(
template_path
,
{
'
leaderboard
'
:
obj
,
'
prev_date
'
:
prev_date
,
'
beat_version
'
:
__version__
,
'
site
'
:
current_site
,
}
render_to_string
(
template_path
,
{
"
leaderboard
"
:
obj
,
"
prev_date
"
:
prev_date
,
"
beat_version
"
:
__version__
,
"
site
"
:
current_site
,
},
),
settings
.
DEFAULT_FROM_EMAIL
,
to
=
[],
...
...
@@ -91,7 +96,11 @@ class Command(BaseCommand):
mesg
.
send
()
else
:
logger
.
debug
(
'
Leaderboard %s did not change or notification is off
'
%
obj
.
search
)
logger
.
debug
(
"
Leaderboard %s did not change or notification is off
"
%
obj
.
search
)
logger
.
info
(
'
Leaderboard updates: %d / Notifications: %d
'
%
\
(
objects_updated
,
objects_changed
))
logger
.
info
(
"
Leaderboard updates: %d / Notifications: %d
"
%
(
objects_updated
,
objects_changed
)
)
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