<commit_before>#!/usr/bin/perl -w
#
# Copyright 2013,2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


use ReportLatency::utils;
use ReportLatency::AtomicFile;
use ReportLatency::Spectrum;
use ReportLatency::StackedGraph;
use ReportLatency::StaticView;
use ReportLatency::Store;
use ReportLatency::Summary;
use DBI;
use GD;
use Getopt::Long;
use Pod::Usage;
use strict;

my $days=14;



sub main() {

  my %options;
  my $r = GetOptions(\%options,
		     'help|?',
		     'man',
		     'verbose')
    or pod2usage(2);
  pod2usage(-verbose => 2) if $options{'man'};
  pod2usage(1) if $options{'help'};

  if ($options{'verbose'}) {
    benchmark_start();
  }

  my $store = new ReportLatency::Store( dsn => latency_dsn('backup') );
  my $dbh = $store->{dbh};

  my $view = new ReportLatency::StaticView($store);

  my $t = time;
  my $begin = $store->db_timestamp($t - $days * 24 * 3600);
  my $end = $store->db_timestamp($t);
  my $summary = new ReportLatency::Summary($store, $begin, $end);

  $view->realize($summary,"tags/summary");

  $dbh->rollback() ||
    die "Unable to rollback, but there should be no changes anyway";

  if ($options{'verbose'}) {
    benchmark_end();
  }
}

main() unless caller();

__END__

=head1 NAME

summary.pl - generate summary total latency spectrum graphs and tables from a sqlite database

=head1 SYNOPSIS

cd data-dir

ls -l latency.sqlite3

cd ../www

summary.pl

 Options:
   -help      brief help message<commit_msg>remove rollback from summary.pl - just cruft.<commit_after>#!/usr/bin/perl -w
#
# Copyright 2013,2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


use ReportLatency::utils;
use ReportLatency::AtomicFile;
use ReportLatency::Spectrum;
use ReportLatency::StackedGraph;
use ReportLatency::StaticView;
use ReportLatency::Store;
use ReportLatency::Summary;
use DBI;
use GD;
use Getopt::Long;
use Pod::Usage;
use strict;

my $days=14;



sub main() {

  my %options;
  my $r = GetOptions(\%options,
		     'help|?',
		     'man',
		     'verbose')
    or pod2usage(2);
  pod2usage(-verbose => 2) if $options{'man'};
  pod2usage(1) if $options{'help'};

  if ($options{'verbose'}) {
    benchmark_start();
  }

  my $store = new ReportLatency::Store( dsn => latency_dsn('backup') );

  my $view = new ReportLatency::StaticView($store);

  my $t = time;
  my $begin = $store->db_timestamp($t - $days * 24 * 3600);
  my $end = $store->db_timestamp($t);
  my $summary = new ReportLatency::Summary($store, $begin, $end);

  $view->realize($summary,"tags/summary");

  if ($options{'verbose'}) {
    benchmark_end();
  }
}

main() unless caller();

__END__

=head1 NAME

summary.pl - generate summary total latency spectrum graphs and tables from a sqlite database

=head1 SYNOPSIS

cd data-dir

ls -l latency.sqlite3

cd ../www

summary.pl

 Options:
   -help      brief help message
{'fraction_non_alphanumeric': 0.12823800974608873, 'fraction_numerical': 0.014875609130546294, 'mean_word_length': 4.051813471502591, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1967868', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1227, 'n_words': 421}