<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace BatchGbViewer
{
   /// <summary>
   /// This partial class is designed to handle everything involved with the GradeBook Tab
   /// </summary>
   public partial class MainWindow : Window
   {

      private static HttpClient users = new HttpClient();
      private static HttpClient exams = new HttpClient();

      /// <summary>
      /// This method will handle the events that occure when the user changes the listbox selection
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void GB_listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
         List<string> x = new List<string>() { };
         //listBatchName.Items.Add(x);
      }


      /// <summary>
      /// The purpose of this method is to get all batches and their content as a List Object.
      /// 
      /// </summary>
      /// <returns></returns>
      private async Task<List<string>> GetBatchList()
      {
         HttpResponseMessage response = await batchClient.GetAsync("./api/Batches");
         response.EnsureSuccessStatusCode(); // throw an error code
         var batch = await response.Content.ReadAsAsync<IEnumerable<Batch>>();
         List<string> batches = new List<string>();

         if (batch != null)
         {
            foreach (Batch b in batch)
            {
               batches.Add(b.Name);
            }
         }

         return batches;
      }


      /// <summary>
      /// This method will handle how the drop down filter is populated
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private async void GB_listBox_Loaded(object sender, RoutedEventArgs e)
      {
         var comboBox = sender as ComboBox;
         comboBox.ItemsSource = await GetBatchList();
         comboBox.SelectedIndex = 0;
      }

      private async void GB_DataGrid_View_Loaded(object sender, RoutedEventArgs e)
      {
         var gridView = sender as DataGrid;
         gridView.ItemsSource = await GetInitialGridView();
      }

      /// <summary>
      /// This method is designed to pre-render the DataGrid view
      /// </summary>
      private async Task<List<Batch>> GetInitialGridView()
      {
         HttpResponseMessage response = await batchClient.GetAsync("./api/Batches");
         response.EnsureSuccessStatusCode(); // throw an error code
         var batch = await response.Content.ReadAsAsync<IEnumerable<Batch>>();
         List<Batch> batches = new List<Batch>();

         if (batch != null)
         {
            foreach (Batch b in batch)
            {
               batches.Add(b);
            }
         }
         return batches;
      }<commit_msg>added in comments and established test_view for GB_DataGrid<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace BatchGbViewer
{
   /// <summary>
   /// This partial class is designed to handle everything involved with the GradeBook Tab
   /// </summary>
   public partial class MainWindow : Window
   {

      private static HttpClient users = new HttpClient();
      private static HttpClient exams = new HttpClient();

      /// <summary>
      /// This method will handle the events that occure when the user changes the listbox selection
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void GB_listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
         List<string> x = new List<string>() { };
         //listBatchName.Items.Add(x);
      }


      /// <summary>
      /// The purpose of this method is to get all batches and their content as a List Object.
      /// 
      /// </summary>
      /// <returns></returns>
      private async Task<List<string>> GetBatchList()
      {
         HttpResponseMessage response = await batchClient.GetAsync("./api/Batches");
         response.EnsureSuccessStatusCode(); // throw an error code
         var batch = await response.Content.ReadAsAsync<IEnumerable<Batch>>();
         List<string> batches = new List<string>();

         if (batch != null)
         {
            foreach (Batch b in batch)
            {
               batches.Add(b.Name);
            }
         }

         return batches;
      }


      /// <summary>
      /// This method will handle how the drop down filter is populated
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private async void GB_listBox_Loaded(object sender, RoutedEventArgs e)
      {
         var comboBox = sender as ComboBox;
         comboBox.ItemsSource = await GetBatchList();
         comboBox.SelectedIndex = 0;
      }

      /// <summary>
      /// This method is called by the Grade Book DataGrid (GB_DataGrid_View) and initializes
      /// the tabular data that the user will see upon opening the tab
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private async void GB_DataGrid_View_Loaded(object sender, RoutedEventArgs e)
      {
         var gridView = sender as DataGrid;
         gridView.ItemsSource = await GetInitialGridView();
      }

      /// <summary>
      /// This method is designed to interlace several API calls and generate the
      /// initial DataGrid view based on the results
      /// </summary>
      private async Task<List<Batch>> GetInitialGridView()
      {
         HttpResponseMessage response = await batchClient.GetAsync("./api/Batches");
         response.EnsureSuccessStatusCode(); // throw an error code
         var batch = await response.Content.ReadAsAsync<IEnumerable<Batch>>();
         List<Batch> batches = new List<Batch>();

         if (batch != null)
         {
            foreach (Batch b in batch)
            {
               batches.Add(b);
            }
         }
         return batches;
      }
{'fraction_non_alphanumeric': 0.11112852664576803, 'fraction_numerical': 0.00031347962382445143, 'mean_word_length': 2.131010794896958, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, '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': '661848', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1631, 'n_words': 511}