<commit_before><?php
require_once 'vendor/autoload.php';
require_once 'NightlyData.php';

// get command-line variable 'locations' if present
$locationBreakdown = (array_search("locations",$argv) ? (array_search("locations",$argv) > 0 ? "locations" : "") : "");

// Configuration
$config = Spyc::YAMLLoad(realpath(dirname(__FILE__)) . '/../../../config/config.yaml');

if (isset($config['nightly']))
{
    // Default Timezone. See: http://us3.php.net/manual/en/timezones.php
    $DEFAULT_TIMEZONE = $config['nightly']['timezone'];
    date_default_timezone_set($DEFAULT_TIMEZONE);

    // Which day to retrieve hourly report
    $DAY_PROCESS = date('Ymd', strtotime('yesterday'));

    // Initialize class and retrieve data
    try
    {
        $data = new NightlyData();
	$data->locationBreakdown = $locationBreakdown;
        $nightlyData = $data->getData($DAY_PROCESS);

        // Print Output

	// Add stylesheet if multiple locations
	if ($locationBreakdown) {
	  print '<style>';
	  print 'table { border-collapse: collapse;}';
	  print 'td,th { border: 1px solid black; text-align: center;}';
	  print '</style>';
	}

        foreach ($nightlyData as $key => $init)
        {
	    if ($locationBreakdown) { 
	      print "<h2>" . $key . "</h2>\n";
	      print ($data->buildLocationStatsTable($nightlyData[$key], $key));
	    }
	    else {
	      print "\n" . $key . "\n";
	      foreach ($init as $key => $count)
		{
		  print " " . $data->hourDisplay[$key] . ': ' . $count . "\n";
		}
	    }
        }
    }
    catch (Exception $e)
    {
        print "Error: " . $e;
    }
}
else
{
    print 'Error: Problem loading config.yaml. Please verify config.yaml exists and contains a valid baseUrl.';
}<commit_msg>nightly.php honors command line args<commit_after><?php
require_once 'vendor/autoload.php';
require_once 'NightlyData.php';

// get command-line variables if present
$possibleArgs = array ("locationBreakdown" => "locations",
		       "hoursAcross" => "hours-across",
		       "outputHtml" => "html");

foreach ($possibleArgs as $config => $arg) 
  {
    $$config = (array_search($arg, $argv) ? (array_search($arg,$argv) > 0 ? true : "") : false);
  }

// Configuration
$config = Spyc::YAMLLoad(realpath(dirname(__FILE__)) . '/../../../config/config.yaml');

if (isset($config['nightly']))
{
    // Default Timezone. See: http://us3.php.net/manual/en/timezones.php
    $DEFAULT_TIMEZONE = $config['nightly']['timezone'];
    date_default_timezone_set($DEFAULT_TIMEZONE);

    // Which day to retrieve hourly report
    $DAY_PROCESS = date('Ymd', strtotime('yesterday'));

    // Initialize class and retrieve data
    try
    {
        $data = new NightlyData();
        $nightlyData = $data->getData($DAY_PROCESS);

        // Print Output

	// Add stylesheet if multiple locations
	if ($locationBreakdown) {
	  print '<style>';
	  print 'table { border-collapse: collapse;}';
	  print 'td,th { border: 1px solid black; text-align: center;}';
	  print 'tr:first-child { font-weight: bold }';
	  print 'td:first-child { font-weight: bold }';
	  print '</style>';
	}

        foreach ($nightlyData as $key => $init)
        {
	  $table = ($data->buildLocationStatsTable($nightlyData[$key], $key));

	  if (! $locationBreakdown) 
	    {
	      $table = $data->eliminateLocations($table);
	    }
	  if ($hoursAcross)
	    {
	      $table = $data->sideways($table);
	    }
	  if ($outputHtml)
	    {
	      print "<h2>" . $key . "</h2>\n";
	      print($data->formatTable($table, "html"));
	    }
	  else 
	    {
	      print "\n" . $key . "\n";
	      print($data->formatTable($table));
	    }
        }
    }
    catch (Exception $e)
    {
        print "Error: " . $e;
    }
}
else
{
    print 'Error: Problem loading config.yaml. Please verify config.yaml exists and contains a valid baseUrl.';
}
{'fraction_non_alphanumeric': 0.17300131061598953, 'fraction_numerical': 0.002621231979030144, 'mean_word_length': 2.8780487804878048, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, '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': '7041263', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1215, 'n_words': 276}