<commit_before>package app.lsgui.rest.twitch;

import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.JsonObject;

import app.lsgui.utils.JSONUtils;
import app.lsgui.utils.Utils;
import javafx.scene.image.Image;

public class TwitchChannelData {

    private static final Logger LOGGER = LoggerFactory.getLogger(TwitchChannelData.class);

    private static final ZoneOffset OFFSET = ZoneOffset.ofHours(-2);
    private static final String PREFIX = "GMT"; // Greenwich Mean Time
    private static final ZoneId GMT = ZoneId.ofOffset(PREFIX, OFFSET);
    private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss'Z'").withZone(GMT);;
    private static final String STREAM = "stream";

    private boolean online = false;
    private String name = "";
    private String title = "";
    private String createdAt = "";
    private String updatedAt = "";
    private String previewURL = "";
    private String logoURL = "";
    private String game = "";
    private long uptime = 0L;
    private int viewers = 0;
    private Image previewImage;
    private Image logoImage;
    private List<String> qualities;

    public TwitchChannelData(final JsonObject channelAPIResponse, final String name) {
        if (channelAPIResponse.get(STREAM) != null && !channelAPIResponse.get(STREAM).isJsonNull()) {
            JsonObject streamObject = channelAPIResponse.get(STREAM).getAsJsonObject();
            if (streamObject != null && !streamObject.get("channel").isJsonNull() && !streamObject.isJsonNull()) {
                setData(streamObject, name);
            }
        } else {
            setData(null, name);
        }

    }

    private void setData(final JsonObject channelObject, final String name) {
        if (channelObject != null) {
            setOnlineData(channelObject, name);
        } else {
            setOfflineData(name);
        }
    }

    private void setOnlineData(final JsonObject channelObject, final String name) {
        JsonObject channel = channelObject.get("channel").getAsJsonObject();
        JsonObject preview = channelObject.get("preview").getAsJsonObject();
        setName(name);
        setTitle(JSONUtils.getStringIfNotNull("status", channel));
        setGame(JSONUtils.getStringIfNotNull("game", channelObject));
        setViewers(JSONUtils.getIntegerIfNotNull("viewers", channelObject));
        setPreviewURL(JSONUtils.getStringIfNotNull("large", preview));
        setCreatedAt(JSONUtils.getStringIfNotNull("created_at", channelObject));
        setUpdatedAt(JSONUtils.getStringIfNotNull("updated_at", channel));
        setLogoURL(JSONUtils.getStringIfNotNull("logo", channel));
        setOnline(true);
        calculateAndSetUptime();
        setPreviewImage(new Image(getPreviewURL()));
        setLogoImage(null);
        setQualities(Utils.getAvailableQuality("http://twitch.tv/" + name));
    }

    private void setOfflineData(final String name) {
        setName(name);
        setTitle("");
        setGame("");
        setViewers(0);
        setPreviewURL("");
        setCreatedAt("");
        setUpdatedAt("");
        setLogoURL("");
        setOnline(false);
        setQualities(new ArrayList<String>());
        setPreviewImage(null);
        setLogoImage(null);
    }

    private void calculateAndSetUptime() {
        try {
            final ZonedDateTime nowDate = ZonedDateTime.now().withZoneSameLocal(GMT);
            ZonedDateTime startDate = ZonedDateTime.parse(getCreatedAt(), DTF);
            long time = startDate.until(nowDate, ChronoUnit.MILLIS);
            // TODO don't correct manually
            final long gmtCorrection = -7200000L;
            time += gmtCorrection;
            setUptime(time);
        } catch (Exception e) {
            LOGGER.error("ERROR while parsing date", e);
            setUptime(0L);
        }
    }

    public boolean isOnline() {
        return online;
    }

    private void setOnline(boolean online) {
        this.online = online;
    }

    public String getName() {
        return name;
    }

    private void setName(String name) {
        this.name = name;
    }

    public String getTitle() {
        return title;
    }

    private void setTitle(String title) {
        this.title = title;
    }

    public int getViewers() {
        return viewers;
    }

    private void setViewers(int viewers) {
        this.viewers = viewers;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    private void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getUpdatedAt() {
        return updatedAt;
    }

    private void setUpdatedAt(String updatedAt) {
        this.updatedAt = updatedAt;
    }

    public String getPreviewURL() {
        return previewURL;
    }

    private void setPreviewURL(String previewURL) {
        this.previewURL = previewURL;
    }

    public String getLogoURL() {
        return logoURL;
    }

    private void setLogoURL(String logoURL) {
        this.logoURL = logoURL;
    }

    public String getGame() {
        return game;
    }

    private void setGame(String game) {
        this.game = game;
    }

    public long getUptime() {
        return uptime;
    }

    private void setUptime(long uptime) {
        this.uptime = uptime;
    }

    public Image getLogoImage() {
        return logoImage;
    }

    private void setLogoImage(Image logoImage) {
        this.logoImage = logoImage;
    }

    public Image getPreviewImage() {
        return previewImage;
    }

    private void setPreviewImage(Image previewImage) {
        this.previewImage = previewImage;
    }

    public List<String> getQualities() {
        return qualities;
    }

    private void setQualities(List<String> qualities) {
        this.qualities = qualities;
    }

}
<commit_msg>try to fix manual correction<commit_after>package app.lsgui.rest.twitch;

import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.JsonObject;

import app.lsgui.utils.JSONUtils;
import app.lsgui.utils.Utils;
import javafx.scene.image.Image;

public class TwitchChannelData {

    private static final Logger LOGGER = LoggerFactory.getLogger(TwitchChannelData.class);

    private static final ZoneOffset OFFSET = ZoneOffset.ofHours(-2);
    private static final String PREFIX = "GMT"; // Greenwich Mean Time
    private static final ZoneId GMT = ZoneId.ofOffset(PREFIX, OFFSET);
    private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss'Z'").withZone(GMT);;
    private static final String STREAM = "stream";

    private boolean online = false;
    private String name = "";
    private String title = "";
    private String createdAt = "";
    private String updatedAt = "";
    private String previewURL = "";
    private String logoURL = "";
    private String game = "";
    private long uptime = 0L;
    private int viewers = 0;
    private Image previewImage;
    private Image logoImage;
    private List<String> qualities;

    public TwitchChannelData(final JsonObject channelAPIResponse, final String name) {
        if (channelAPIResponse.get(STREAM) != null && !channelAPIResponse.get(STREAM).isJsonNull()) {
            JsonObject streamObject = channelAPIResponse.get(STREAM).getAsJsonObject();
            if (streamObject != null && !streamObject.get("channel").isJsonNull() && !streamObject.isJsonNull()) {
                setData(streamObject, name);
            }
        } else {
            setData(null, name);
        }

    }

    private void setData(final JsonObject channelObject, final String name) {
        if (channelObject != null) {
            setOnlineData(channelObject, name);
        } else {
            setOfflineData(name);
        }
    }

    private void setOnlineData(final JsonObject channelObject, final String name) {
        JsonObject channel = channelObject.get("channel").getAsJsonObject();
        JsonObject preview = channelObject.get("preview").getAsJsonObject();
        setName(name);
        setTitle(JSONUtils.getStringIfNotNull("status", channel));
        setGame(JSONUtils.getStringIfNotNull("game", channelObject));
        setViewers(JSONUtils.getIntegerIfNotNull("viewers", channelObject));
        setPreviewURL(JSONUtils.getStringIfNotNull("large", preview));
        setCreatedAt(JSONUtils.getStringIfNotNull("created_at", channelObject));
        setUpdatedAt(JSONUtils.getStringIfNotNull("updated_at", channel));
        setLogoURL(JSONUtils.getStringIfNotNull("logo", channel));
        setOnline(true);
        calculateAndSetUptime();
        setPreviewImage(new Image(getPreviewURL()));
        setLogoImage(null);
        setQualities(Utils.getAvailableQuality("http://twitch.tv/" + name));
    }

    private void setOfflineData(final String name) {
        setName(name);
        setTitle("");
        setGame("");
        setViewers(0);
        setPreviewURL("");
        setCreatedAt("");
        setUpdatedAt("");
        setLogoURL("");
        setOnline(false);
        setQualities(new ArrayList<String>());
        setPreviewImage(null);
        setLogoImage(null);
    }

    private void calculateAndSetUptime() {
        try {
            final ZonedDateTime nowDate = ZonedDateTime.now(GMT);
            ZonedDateTime startDate = ZonedDateTime.parse(getCreatedAt(), DTF);
            long time = startDate.until(nowDate, ChronoUnit.MILLIS);
            setUptime(time);
        } catch (Exception e) {
            LOGGER.error("ERROR while parsing date", e);
            setUptime(0L);
        }
    }

    public boolean isOnline() {
        return online;
    }

    private void setOnline(boolean online) {
        this.online = online;
    }

    public String getName() {
        return name;
    }

    private void setName(String name) {
        this.name = name;
    }

    public String getTitle() {
        return title;
    }

    private void setTitle(String title) {
        this.title = title;
    }

    public int getViewers() {
        return viewers;
    }

    private void setViewers(int viewers) {
        this.viewers = viewers;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    private void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getUpdatedAt() {
        return updatedAt;
    }

    private void setUpdatedAt(String updatedAt) {
        this.updatedAt = updatedAt;
    }

    public String getPreviewURL() {
        return previewURL;
    }

    private void setPreviewURL(String previewURL) {
        this.previewURL = previewURL;
    }

    public String getLogoURL() {
        return logoURL;
    }

    private void setLogoURL(String logoURL) {
        this.logoURL = logoURL;
    }

    public String getGame() {
        return game;
    }

    private void setGame(String game) {
        this.game = game;
    }

    public long getUptime() {
        return uptime;
    }

    private void setUptime(long uptime) {
        this.uptime = uptime;
    }

    public Image getLogoImage() {
        return logoImage;
    }

    private void setLogoImage(Image logoImage) {
        this.logoImage = logoImage;
    }

    public Image getPreviewImage() {
        return previewImage;
    }

    private void setPreviewImage(Image previewImage) {
        this.previewImage = previewImage;
    }

    public List<String> getQualities() {
        return qualities;
    }

    private void setQualities(List<String> qualities) {
        this.qualities = qualities;
    }

}

{'fraction_non_alphanumeric': 0.10135415801279389, 'fraction_numerical': 0.001744620752679239, 'mean_word_length': 2.667885435709933, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '825600', 'n_tokens_mistral': 3425, 'n_tokens_neox': 3323, 'n_words': 764}