<commit_before>package com.paulhammant.buildradiator.radiator;

import com.paulhammant.buildradiator.radiator.model.*;
import org.jooby.Err;
import org.jooby.Jooby;
import org.jooby.Request;
import org.jooby.Response;
import org.jooby.json.Jackson;

@SuppressWarnings({"unchecked", "rawtypes"})
public class RadiatorApp extends Jooby {

    public static final String DEMO_RADIATOR_CODE = "ueeusvcipmtsb755uq";
    public static final String NO_UPDATES = "NO-UPDATES";
    public static final String HTML_PAGE = "radiator/radiator.html";
    public static final String VUE_COMPONENT = "radiator/radiator.vue";

    protected final RadiatorStore radiatorStore;

    public static void main(final String[] args) {
        Jooby.run(RadiatorApp::new, args);
    }

    {

        String gae_appId = System.getenv("GCLOUD_PROJECT");

        use(new Jackson());

        if (gae_appId != null) {
            radiatorStore = new RadiatorStore.BackedByGoogleCloudDataStore();
        } else {
            radiatorStore = new RadiatorStore();
        }

        before((req, rsp) -> {
            try {
                if (gae_appId != null && req.header("X-Forwarded-Proto").value().equals("http")) {
                    rsp.redirect("https://" + req.hostname() + req.path());
                }
            } catch (Throwable throwable) {
                rsp.send(req.path()+ " (before) " + throwable.getMessage());
            }
        });

        serveRadiatorPage();
        serveRadiatorComponent();

        path(getBasePath(), () -> {
            // used by radiator.html
            get("/:radiatorCode/", this::getRadiatorByCode);
            post("/:radiatorCode/stepPassed", this::stepPassed);
            post("/:radiatorCode/stepFailed", this::stepFailed);
            post("/:radiatorCode/startStep", this::startStep);
            post("/:radiatorCode/buildCancelled", this::buildCancelled);
            post("/:radiatorCode/updateIps", this::updateIps);
            post("/create", this::createRadiator);

        });

        err(RadiatorDoesntExist.class, (req, rsp, err) -> {
            rsp.status(200);
            nothingHere(req, rsp);
        });

        err(BuildRadiatorException.class, (req, rsp, err) -> {
            rsp.status(200);
            rsp.send(err.getCause().getMessage());
        });

        err(Err.Missing.class, (req, rsp, err) -> {
            rsp.status(200);
            String message = err.getMessage();
            rsp.send(message.substring(message.indexOf(":")+2));
        });

        err((req, rsp, err) -> {
            rsp.status(200);
            nothingHere(req, rsp);
        });

        err(404, (req, rsp, err) -> {
            System.out.println(req.route() + " page missing from " + req.ip());
            rsp.status(404);
            rsp.send("");
        });

        err(405, (req, rsp, err) -> {
            System.out.println(req.route() + " blocked from " + req.ip() + ", type:" + req.type());
            rsp.status(404);
            rsp.send("");
        });

        onStart(this::starterData);

    }

    public String getBasePath() {
        return "";
    }
<commit_msg>not needed?<commit_after>package com.paulhammant.buildradiator.radiator;

import com.paulhammant.buildradiator.radiator.model.*;
import org.jooby.Err;
import org.jooby.Jooby;
import org.jooby.Request;
import org.jooby.Response;
import org.jooby.json.Jackson;

@SuppressWarnings({"unchecked", "rawtypes"})
public class RadiatorApp extends Jooby {

    public static final String DEMO_RADIATOR_CODE = "ueeusvcipmtsb755uq";
    public static final String NO_UPDATES = "NO-UPDATES";
    public static final String HTML_PAGE = "radiator/radiator.html";
    public static final String VUE_COMPONENT = "radiator/radiator.vue";

    protected final RadiatorStore radiatorStore;

    public static void main(final String[] args) {
        Jooby.run(RadiatorApp::new, args);
    }

    {

        String gae_appId = System.getenv("GCLOUD_PROJECT");

        use(new Jackson());

        if (gae_appId != null) {
            radiatorStore = new RadiatorStore.BackedByGoogleCloudDataStore();
        } else {
            radiatorStore = new RadiatorStore();
        }

        before((req, rsp) -> {
            try {
                if (gae_appId != null && req.header("X-Forwarded-Proto").value().equals("http")) {
                    rsp.redirect("https://" + req.hostname() + req.path());
                }
            } catch (Throwable throwable) {
                rsp.send(req.path()+ " (before) " + throwable.getMessage());
            }
        });

        serveRadiatorPage();
        serveRadiatorComponent();

        path(getBasePath(), () -> {
            // used by radiator.html
            get("/:radiatorCode/", this::getRadiatorByCode);
            post("/:radiatorCode/stepPassed", this::stepPassed);
            post("/:radiatorCode/stepFailed", this::stepFailed);
            post("/:radiatorCode/startStep", this::startStep);
            post("/:radiatorCode/buildCancelled", this::buildCancelled);
            post("/:radiatorCode/updateIps", this::updateIps);
            post("/create", this::createRadiator);

        });

        err(RadiatorDoesntExist.class, (req, rsp, err) -> {
            rsp.status(200);
            nothingHere(req, rsp);
        });

        err(BuildRadiatorException.class, (req, rsp, err) -> {
            rsp.status(200);
            rsp.send(err.getCause().getMessage());
        });

//        err(Err.Missing.class, (req, rsp, err) -> {
//            rsp.status(200);
//            String message = err.getMessage();
//            rsp.send(message.substring(message.indexOf(":")+2));
//        });

        err((req, rsp, err) -> {
            rsp.status(200);
            nothingHere(req, rsp);
        });

        err(404, (req, rsp, err) -> {
            System.out.println(req.route() + " page missing from " + req.ip());
            rsp.status(404);
            rsp.send("");
        });

        err(405, (req, rsp, err) -> {
            System.out.println(req.route() + " blocked from " + req.ip() + ", type:" + req.type());
            rsp.status(404);
            rsp.send("");
        });

        onStart(this::starterData);

    }

    public String getBasePath() {
        return "";
    }

{'fraction_non_alphanumeric': 0.15227056208320103, 'fraction_numerical': 0.00889171165449349, 'mean_word_length': 2.115232443125618, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '19998', 'n_tokens_mistral': 2026, 'n_tokens_neox': 1912, 'n_words': 329}