Commit a19e113e authored by Robert Czechowski's avatar Robert Czechowski

Allow for deactivation of contestresult page to reduce load

parent 32353203
Pipeline #440 passed with stages
in 28 minutes and 40 seconds
......@@ -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 {
......
......@@ -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());
......
......@@ -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()?;
......
<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>
../default/nocontestresults.hbs
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment