DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (d5c3254b3e56)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
#!/usr/bin/perl -w
# -*- Mode: cperl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is Litmus.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Zach Lipton <zach@zachlipton.com>
#                 Chris Cooper <ccooper@deadsquid.com>

use strict;

use Litmus;
use Litmus::Error;
use Litmus::FormWidget;
use Litmus::UserAgentDetect;
use Litmus::SysConfig;
use Litmus::Auth;
use Litmus::Utils;
use Litmus::TestEvent;

use CGI;
use Date::Manip;
use JSON -convert_blessed_universally;

Litmus->init();
my $c = Litmus->cgi(); 

print $c->header();

my $vars;

$vars->{'title'} = "Testday Report";

my $product_id;
if ($c->param) {
  my $testday;
  if ($c->param("testday_id")) {    
    $testday = Litmus::TestEvent->new(testday_id => $c->param("testday_id"));
    $product_id = $testday->getProductId();
  } elsif ($c->param("start_timestamp") and 
           $c->param("finish_timestamp")) {
    my @subgroups;
    if ($c->param('subgroup')) {
      my @subgroup_ids = $c->param('subgroup');
      foreach my $subgroup_id (@subgroup_ids) {
        push @subgroups, Litmus::DB::Subgroup->retrieve($subgroup_id);
      }
    }
    my $product_id = quotemeta($c->param("product"));
    $testday = Litmus::TestEvent->new(
                                      (start_timestamp => $c->param("start_timestamp"),
                                       finish_timestamp => $c->param("finish_timestamp"),
                                       product_id => $c->param("product"),
                                       branch_id => $c->param("branch"),
                                       testgroup_id => $c->param("testgroup"),
                                       subgroups => \@subgroups,
                                       build_id => $c->param("build_id"),
                                       locale => $c->param("locale"),
                                      )
                                     );    
  }

  my $include_admin = 0;
  if ($c->param("include_admin")) { 
    $include_admin = 1;
  }
   
  if ($testday) {
    $vars->{'title'} .= " - " . $testday->getDescription . ", " . $testday->getStartTimestamp(1) . " - " . $testday->getFinishTimestamp(1);

    $vars->{'display_results'} = 1;
    $vars->{'locale_results'} = $testday->getBreakdownByLocale($include_admin);
    $vars->{'platform_results'} = $testday->getBreakdownByPlatform($include_admin);
    $vars->{'status_results'} = $testday->getBreakdownByResultStatus($include_admin);
    $vars->{'subgroup_results'} = $testday->getBreakdownBySubgroup($include_admin);
    $vars->{'user_results'} = $testday->getBreakdownByUser($include_admin);
    $vars->{'user_status_results'} = $testday->getBreakdownByUserAndResultStatus($include_admin);

    $vars->{'test_event'} = $testday;
  }
}

my $user =  Litmus::Auth::getCurrentUser();
if ($user) {
  $vars->{"defaultemail"} = $user;
  if ($product_id) {
    if ($user->isProductAdmin($product_id)) {
      $vars->{"show_admin"} = $user;
    }
  } else {
    if ($user->is_admin()) {
      $vars->{"show_admin"} = $user;    
    }
  }
}

my $products = Litmus::FormWidget->getProducts;
my $branches = Litmus::FormWidget->getBranches;
my $testgroups = Litmus::FormWidget->getTestgroups;
my $json = new JSON;
my $products_js = $json->allow_unknown->convert_blessed->encode($products);
my $branches_js = $json->allow_unknown->convert_blessed->encode($branches);
my $testgroups_js = $json->allow_unknown->convert_blessed->encode($testgroups);

$vars->{'products_js'} = $products_js;
$vars->{'branches_js'} = $branches_js;
$vars->{'testgroups_js'} = $testgroups_js;

my $locales = Litmus::FormWidget->getLocales;
my $testdays = Litmus::FormWidget->getTestdays;
$vars->{'locales'} = $locales;
$vars->{'testdays'} = $testdays;

Litmus->template()->process("reporting/testday_report.tmpl", $vars) || 
  internalError(Litmus->template()->error());