<commit_before>package info.nightscout.androidaps.data;

import java.util.Date;
import java.util.List;

import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.OpenAPSAMA.Autosens;
import info.nightscout.androidaps.plugins.OpenAPSAMA.AutosensResult;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.client.data.NSProfile;

/**
 * Created by mike on 04.01.2017.
 */
public class MealData {
    public double boluses = 0d;
    public double carbs = 0d;
    public double mealCOB = 0.0d;


    public void addTreatment(Treatment treatment) {
        NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
        if (profile == null) return;

        List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime((long) (new Date().getTime() - 60 * 60 * 1000L * profile.getDia() * 2), false);

        long now = new Date().getTime();
        long dia_ago = now - (new Double(profile.getDia() * 60 * 60 * 1000l)).longValue();
        long t = treatment.created_at.getTime();
        if (t > dia_ago && t <= now) {
            if (treatment.carbs >= 1) {
                carbs += treatment.carbs;
                if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
                    AutosensResult result = Autosens.detectSensitivityandCarbAbsorption(bgReadings, t);
                    double myCarbsAbsorbed = result.carbsAbsorbed;
                    double myMealCOB = Math.max(0, carbs - myCarbsAbsorbed);
                    mealCOB = Math.max(mealCOB, myMealCOB);
                }
            }
            if (treatment.insulin > 0 && treatment.mealBolus) {
                boluses += treatment.insulin;
            }
        }
    }
}
<commit_msg>calculate cob 1.5 * DIA to the past<commit_after>package info.nightscout.androidaps.data;

import java.util.Date;
import java.util.List;

import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.OpenAPSAMA.Autosens;
import info.nightscout.androidaps.plugins.OpenAPSAMA.AutosensResult;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.client.data.NSProfile;

/**
 * Created by mike on 04.01.2017.
 */
public class MealData {
    public double boluses = 0d;
    public double carbs = 0d;
    public double mealCOB = 0.0d;


    public void addTreatment(Treatment treatment) {
        NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
        if (profile == null) return;

        List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime((long) (new Date().getTime() - 60 * 60 * 1000L * profile.getDia() * 2), false);

        long now = new Date().getTime();
        long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
        long t = treatment.created_at.getTime();
        if (t > dia_ago && t <= now) {
            if (treatment.carbs >= 1) {
                carbs += treatment.carbs;
                if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
                    AutosensResult result = Autosens.detectSensitivityandCarbAbsorption(bgReadings, t);
                    double myCarbsAbsorbed = result.carbsAbsorbed;
                    double myMealCOB = Math.max(0, carbs - myCarbsAbsorbed);
                    mealCOB = Math.max(mealCOB, myMealCOB);
                }
            }
            if (treatment.insulin > 0 && treatment.mealBolus) {
                boluses += treatment.insulin;
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.11130876747141041, 'fraction_numerical': 0.017280813214739517, 'mean_word_length': 2.7557251908396947, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5935319', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1198, 'n_words': 231}