Exemplo n.º 1
0
        public static async Task FillTableWithDataFromLog()
        {
            Functions.StarsTable          table      = new Functions.StarsTable(GetConnectionString());
            Dictionary <string, DateTime> gazerDates = GitHubAPI.GetGazerDatesFromLog("../../../data/gazerDates.csv");
            DateTime created = DateTime.Parse("2018-01-04T03:34:45Z").Date;

            int totalDays = (DateTime.UtcNow.Date - created).Days + 1;

            DateTime[] days = Enumerable.Range(0, totalDays).Select(i => created.AddDays(i)).ToArray();

            int[] newStarsByDay = new int[totalDays];
            foreach ((_, DateTime dt) in gazerDates)
            {
                newStarsByDay[(dt - created).Days] += 1;
            }

            int[] totalStarsByDay = new int[totalDays];
            totalStarsByDay[0] = newStarsByDay[0];
            for (int i = 1; i < totalDays; i++)
            {
                totalStarsByDay[i] = totalStarsByDay[i - 1] + newStarsByDay[i];
            }

            for (int i = 0; i < totalDays; i++)
            {
                DateTime day   = days[i];
                int      stars = totalStarsByDay[i];
                await table.Insert("scottplot", "scottplot", stars, day);
            }
        }
Exemplo n.º 2
0
        public static async Task AddCurrentStarsToTable()
        {
            (_, string json) = GitHubAPI.RequestRepo("scottplot", "scottplot", GetGitHubToken());
            int stars = GitHubAPI.TotalStars(json);

            Functions.StarsTable table = new Functions.StarsTable(GetConnectionString());
            await table.Insert("scottplot", "scottplot", stars, DateTime.Now);
        }