<commit_before>package uk.co.pilllogger.mappers;

import android.util.SparseIntArray;

import org.joda.time.DateTime;
import org.joda.time.Days;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import uk.co.pilllogger.models.Consumption;
import uk.co.pilllogger.models.Pill;

/**
 * Created by alex on 21/11/2013.
 */
public class ConsumptionMapper {

    public static Map<Pill, SparseIntArray> mapByPillAndDate(List<Consumption> consumptions, int days){

        DateTime to = new DateTime();
        DateTime from = to.minusDays(days);

        return mapByPillAndDate(consumptions, from, to);
    }

    public static Map<Pill, SparseIntArray> mapByPillAndDate(List<Consumption> consumptions, DateTime from){
        return mapByPillAndDate(consumptions, from, new DateTime());
    }

    public static Map<Pill, SparseIntArray> mapByPillAndDate(List<Consumption> consumptions, DateTime from, DateTime to){
        HashMap<Pill, SparseIntArray> xPoints = new HashMap<Pill, SparseIntArray>();

        for (Consumption c : consumptions) {
            Pill pill = c.get_pill();
            DateTime consumptionDate = new DateTime(c.get_date());

            if(consumptionDate.isBefore(from) || consumptionDate.isAfter(to)) break;

            Days days = Days.daysBetween(from.withTimeAtStartOfDay(), consumptionDate.plusDays(1).withTimeAtStartOfDay());
            int x = days.getDays();

            SparseIntArray currentLineValues;
            if(xPoints.containsKey(pill)) {
                currentLineValues = xPoints.get(pill);
            }
            else{
                currentLineValues = new SparseIntArray();<commit_msg>Fixed consumption data not showing up for 'today'<commit_after>package uk.co.pilllogger.mappers;

import android.util.SparseIntArray;

import org.joda.time.DateTime;
import org.joda.time.Days;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import uk.co.pilllogger.models.Consumption;
import uk.co.pilllogger.models.Pill;

/**
 * Created by alex on 21/11/2013.
 */
public class ConsumptionMapper {

    public static Map<Pill, SparseIntArray> mapByPillAndDate(List<Consumption> consumptions, int days){

        DateTime to = new DateTime();
        DateTime from = to.minusDays(days);

        return mapByPillAndDate(consumptions, from, to);
    }

    public static Map<Pill, SparseIntArray> mapByPillAndDate(List<Consumption> consumptions, DateTime from){
        return mapByPillAndDate(consumptions, from, new DateTime());
    }

    public static Map<Pill, SparseIntArray> mapByPillAndDate(List<Consumption> consumptions, DateTime from, DateTime to){
        HashMap<Pill, SparseIntArray> xPoints = new HashMap<Pill, SparseIntArray>();

        for (Consumption c : consumptions) {
            Pill pill = c.get_pill();
            DateTime consumptionDate = new DateTime(c.get_date());

            if(consumptionDate.isBefore(from) || consumptionDate.isAfter(to)) break;

            Days days = Days.daysBetween(from.withTimeAtStartOfDay(), consumptionDate.withTimeAtStartOfDay());
            int x = days.getDays();

            SparseIntArray currentLineValues;
            if(xPoints.containsKey(pill)) {
                currentLineValues = xPoints.get(pill);
            }
            else{
                currentLineValues = new SparseIntArray();
{'fraction_non_alphanumeric': 0.1029236276849642, 'fraction_numerical': 0.005071599045346062, 'mean_word_length': 3.2713375796178346, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4555136', 'n_tokens_mistral': 1009, 'n_tokens_neox': 982, 'n_words': 214}