コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #3
0
        public static void MakeGraph()
        {
            var table = new Functions.StarsTable(GetConnectionString());

            System.Drawing.Bitmap bmp = table.GetGraphBitmap();
            string saveFilePath       = Path.GetFullPath("test.png");

            bmp.Save(saveFilePath, System.Drawing.Imaging.ImageFormat.Png);
            Console.WriteLine($"Saved: {saveFilePath}");
        }