Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
a19e113e
Commit
a19e113e
authored
Feb 20, 2020
by
Robert Czechowski
Browse files
Allow for deactivation of contestresult page to reduce load
parent
32353203
Pipeline
#440
passed with stages
in 28 minutes and 40 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/config.rs
View file @
a19e113e
...
...
@@ -16,6 +16,7 @@ pub struct Config {
pub
no_contest_scan
:
Option
<
bool
>
,
pub
open_browser
:
Option
<
bool
>
,
pub
cookie_signing_secret
:
Option
<
String
>
,
pub
disable_results_page
:
Option
<
bool
>
,
}
#[derive(StructOpt,
Debug)]
...
...
@@ -52,6 +53,10 @@ pub struct Opt {
/// Automatically open medal in the default browser
#[structopt(short
=
"b"
,
long
=
"browser"
)]
pub
openbrowser
:
bool
,
/// Disable results page to reduce load on the server
#[structopt(long
=
"disable-results-page"
)]
pub
disableresultspage
:
bool
,
}
pub
fn
read_config_from_file
(
file
:
&
Path
)
->
Config
{
...
...
src/main.rs
View file @
a19e113e
...
...
@@ -206,6 +206,7 @@ fn main() {
opt
.port
.map
(|
x
|
config
.port
=
Some
(
x
));
config
.no_contest_scan
=
if
opt
.nocontestscan
{
Some
(
true
)
}
else
{
config
.no_contest_scan
};
config
.open_browser
=
if
opt
.openbrowser
{
Some
(
true
)
}
else
{
config
.open_browser
};
config
.disable_results_page
=
if
opt
.disableresultspage
{
Some
(
true
)
}
else
{
config
.disable_results_page
};
// Use default database file if none set
config
.database_file
.get_or_insert
(
Path
::
new
(
"medal.db"
)
.to_owned
());
...
...
src/webfw_iron.rs
View file @
a19e113e
...
...
@@ -447,6 +447,19 @@ fn contest<C>(req: &mut Request) -> IronResult<Response>
fn
contestresults
<
C
>
(
req
:
&
mut
Request
)
->
IronResult
<
Response
>
where
C
:
MedalConnection
+
std
::
marker
::
Send
+
'static
{
let
disable_contest_results
=
{
let
mutex
=
req
.get
::
<
Write
<
SharedConfiguration
>>
()
.unwrap
();
let
config
=
mutex
.lock
()
.unwrap_or_else
(|
e
|
e
.into_inner
());
config
.disable_results_page
.unwrap_or
(
false
)
};
if
disable_contest_results
{
let
mut
resp
=
Response
::
new
();
resp
.set_mut
(
Template
::
new
(
&
"nocontestresults"
,
2
))
.set_mut
(
status
::
Locked
);
return
Ok
(
resp
);
}
let
contest_id
=
req
.expect_int
::
<
i32
>
(
"contestid"
)
?
;
let
session_token
=
req
.require_session_token
()
?
;
...
...
templates/default/nocontestresults.hbs
0 → 100644
View file @
a19e113e
<html>
<body>
<h1>
423: Seite gesperrt
</h1>
<p>
Diese Seite ist zur Zeit deaktiviert um die Serverlast zu minimieren und einen reibungslosen Wettbewerb zu ermöglichen. Bitte probieren Sie es später noch einmal!
</p>
</body>
</html>
templates/jwinf/nocontestresults.hbs
0 → 120000
View file @
a19e113e
../default/nocontestresults.hbs
\ No newline at end of file
Write
Preview
Markdown
is supported
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