<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;
using WebApp.Models;

namespace WebApp.Controllers
{
    public class GraphController : Controller
    {
        // GET: Graph
        public ActionResult Index(string span = null)
        {
            var timeSpan = -1;
            switch (span)
            {
                case "2d":
                    timeSpan = -2;
                    break;
                case "1w":
                    timeSpan = -7;
                    break;
                case "1d":
                default:
                    timeSpan = -1;
                    break;
            }
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("tempandhumid");

            // Construct the query operation for all customer entities where PartitionKey="Smith".
            TableQuery<TempAndHumid> query = new TableQuery<TempAndHumid>().Where(TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThanOrEqual, DateTimeOffset.Now.AddDays(timeSpan).Date));
            var entities = table.ExecuteQuery(query);
            var jsonData = entities.Select(e => new DataDTO()
            {
                Temp = e.temp,
                Timestamp = e.Timestamp.ToLocalTime().ToString("O"),
                Humidity = e.humidity
            });
            var json = JsonConvert.SerializeObject(jsonData);
            ViewBag.Data = json;
            return View();
        }
         
    }

    public class DataDTO
    {
        public double Humidity { get; set; }
        public string Timestamp { get; set; }
        public double Temp { get; set; }
    }
}<commit_msg>Fixes #2 by adding ordering on the timestamp<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;
using WebApp.Models;

namespace WebApp.Controllers
{
    public class GraphController : Controller
    {
        // GET: Graph
        public ActionResult Index(string span = null)
        {
            var timeSpan = -1;
            switch (span)
            {
                case "2d":
                    timeSpan = -2;
                    break;
                case "1w":
                    timeSpan = -7;
                    break;
                case "1d":
                default:
                    timeSpan = -1;
                    break;
            }
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "people" table.
            CloudTable table = tableClient.GetTableReference("tempandhumid");

            // Construct the query operation for all customer entities where PartitionKey="Smith".
            TableQuery<TempAndHumid> query = new TableQuery<TempAndHumid>().Where(TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThanOrEqual, DateTimeOffset.Now.AddDays(timeSpan).Date));
            var entities = table.ExecuteQuery(query);
            var jsonData = entities.OrderBy(x => x.Timestamp).Select(e => new DataDTO()
            {
                Temp = e.temp,
                Timestamp = e.Timestamp.ToLocalTime().ToString("O"),
                Humidity = e.humidity
            });
            var json = JsonConvert.SerializeObject(jsonData);
            ViewBag.Data = json;
            return View();
        }
         
    }

    public class DataDTO
    {
        public double Humidity { get; set; }
        public string Timestamp { get; set; }
        public double Temp { get; set; }
    }
}
{'fraction_non_alphanumeric': 0.08678903240426014, 'fraction_numerical': 0.003399048266485384, 'mean_word_length': 1.8736979166666667, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 10, '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': '3088588', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1059, 'n_words': 270}