<commit_before>
const https = require("https");
const auth = require("./myNetatmoAuth.js");

//zürich
const cityId = 2657896;
//api key für <EMAIL> from openweathermap.org
const apiKey = auth().apiKeyOpenweathermap;

module.exports = {
    sunshineForecast: function (response) {
        const result = {};
        result.sunshine = 0;
        result.type = "sun";
        doRequest(response, result);
    },
    thunderstormForecast: function (response) {
        const result = {};
        result.thunderstorm = 0;
        result.type = "thunderstorm";
        doRequest(response, result);
    }

};

function doRequest(response, result) {

    https.get("https://api.openweathermap.org/data/2.5/forecast?id=" + cityId + "&appid=" + apiKey, (resp) => {
        var data = "";
        // A chunk of data has been recieved.
        resp.on("data", (chunk) => {
            data += chunk;
        });
        resp.on("end", () => {
            let weather = JSON.parse(data);

            switch (result.type) {
                case "sun":
                    result.sunshine = 0;
                    if (weather.cnt > 2) {
                        //the sun shines only on daytime --> "d"
                        let hours3 = weather.list[0].sys.pod === "d";
                        let hours6 = weather.list[1].sys.pod === "d";
                        if (hours3 === "d" || hours6 === "d") {
                            for (let i = 0; i < 2; i++) {
                                let weatherId = weather.list[i].weather.id;
                                //weather cond. ids: https://openweathermap.org/weather-conditions
                                if (weatherId >= 800 && weatherId < 803) {
                                    result.sunshine = 1;
                                }
                            }
                        }
                    }
                    response.end(JSON.stringify(result));
                    break;

                case "thunderstorm":
                    result.thunderstorm = 0;
                    if (weather.cnt > 1) {
                        let weatherId = weather.list[0].weather.id;
                        //weather cond. ids: https://openweathermap.org/weather-conditions
                        if (weatherId >= 200 && weatherId < 232) {
                            result.thunderstorm = 1;
                        }
                    }
                    response.end(JSON.stringify(result));
                    break;
                default:
                    result.type = "error";
                    response.end(JSON.stringify(result));
                    break;
            }

        });
    }).on("error", (err) => {
        console.log("Error: " + err.message);
        response.end(JSON.stringify(result));
    });<commit_msg>replaced let with const, var<commit_after>
const https = require("https");
const auth = require("./myNetatmoAuth.js");

//zürich
const cityId = 2657896;
//api key für <EMAIL> from openweathermap.org
const apiKey = auth().apiKeyOpenweathermap;

module.exports = {
    sunshineForecast: function (response) {
        const result = {};
        result.sunshine = 0;
        result.type = "sun";
        doRequest(response, result);
    },
    thunderstormForecast: function (response) {
        const result = {};
        result.thunderstorm = 0;
        result.type = "thunderstorm";
        doRequest(response, result);
    }

};

function doRequest(response, result) {

    https.get("https://api.openweathermap.org/data/2.5/forecast?id=" + cityId + "&appid=" + apiKey, (resp) => {
        var data = "";
        // A chunk of data has been recieved.
        resp.on("data", (chunk) => {
            data += chunk;
        });
        resp.on("end", () => {
            const weather = JSON.parse(data);

            switch (result.type) {
                case "sun":
                    result.sunshine = 0;
                    if (weather.cnt > 2) {
                        //the sun shines only on daytime --> "d"
                        const hours3 = weather.list[0].sys.pod === "d";
                        const hours6 = weather.list[1].sys.pod === "d";
                        if (hours3 === "d" || hours6 === "d") {
                            for (var i = 0; i < 2; i++) {
                                const weatherId = weather.list[i].weather.id;
                                //weather cond. ids: https://openweathermap.org/weather-conditions
                                if (weatherId >= 800 && weatherId < 803) {
                                    result.sunshine = 1;
                                }
                            }
                        }
                    }
                    response.end(JSON.stringify(result));
                    break;

                case "thunderstorm":
                    result.thunderstorm = 0;
                    if (weather.cnt > 1) {
                        const weatherId = weather.list[0].weather.id;
                        //weather cond. ids: https://openweathermap.org/weather-conditions
                        if (weatherId >= 200 && weatherId < 232) {
                            result.thunderstorm = 1;
                        }
                    }
                    response.end(JSON.stringify(result));
                    break;
                default:
                    result.type = "error";
                    response.end(JSON.stringify(result));
                    break;
            }

        });
    }).on("error", (err) => {
        console.log("Error: " + err.message);
        response.end(JSON.stringify(result));
    });
{'fraction_non_alphanumeric': 0.12688019819500973, 'fraction_numerical': 0.013448947089010795, 'mean_word_length': 1.174682570219315, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3577418', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1420, 'n_words': 310}