# CREATE TABLE job_old (LIKE Job);
# INSERT INTO job_old
# (SELECT * FROM Job WHERE JobId NOT IN (SELECT JobId FROM job_old) );
-my $jobt = $conf->{stat_job_table} || 'Job';
+my $jobt = $bweb->get_stat_table();
my $graph = CGI::param('graph') || 'job_size';
my $legend = CGI::param('legend') || 'on' ;
my ($limitq, $label) = $bweb->get_limit(age => $arg->{age},
limit => $arg->{limit},
offset=> $arg->{offset},
- order => "$jobt.StartTime ASC",
+ order => "Job.StartTime ASC",
);
my $statusq='';
if ($arg->{status} and $arg->{status} ne 'Any') {
- $statusq = " AND $jobt.JobStatus = '$arg->{status}' ";
+ $statusq = " AND Job.JobStatus = '$arg->{status}' ";
}
my $levelq='';
if ($arg->{level} and $arg->{level} ne 'Any') {
- $levelq = " AND $jobt.Level = '$arg->{level}' ";
+ $levelq = " AND Job.Level = '$arg->{level}' ";
}
my $filesetq='';
my $jobnameq='';
if ($arg->{jjobnames}) {
- $jobnameq = " AND $jobt.Name IN ($arg->{jjobnames}) ";
+ $jobnameq = " AND Job.Name IN ($arg->{jjobnames}) ";
} else {
$arg->{jjobnames} = 'all'; # skip warning
}
my $all = $dbh->selectall_arrayref("
SELECT $bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime)
- $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime))
- AS duration, $order, JobId, $jobt.Name
+ AS duration, $order, JobId, Job.Name
- FROM $jobt, Client $filter $groupf
-WHERE $jobt.ClientId = Client.ClientId
- AND $jobt.Type = 'B'
+ FROM $jobt AS Job, Client $filter $groupf
+WHERE Job.ClientId = Client.ClientId
+ AND Job.Type = 'B'
$clientq
$statusq
$levelq
my $query = "
SELECT
- UNIX_TIMESTAMP($jobt.StartTime) AS starttime,
- Client.Name AS clientname,
- $jobt.Name AS jobname,
- $jobt.JobBytes AS jobbytes
-FROM $jobt, FileSet, Client $filter $groupf
-WHERE $jobt.ClientId = Client.ClientId
- AND $jobt.FileSetId = FileSet.FileSetId
- AND $jobt.Type = 'B'
+ UNIX_TIMESTAMP(Job.StartTime) AS starttime,
+ Client.Name AS clientname,
+ Job.Name AS jobname,
+ Job.JobBytes AS jobbytes
+FROM $jobt AS Job, FileSet, Client $filter $groupf
+WHERE Job.ClientId = Client.ClientId
+ AND Job.FileSetId = FileSet.FileSetId
+ AND Job.Type = 'B'
$clientq
$statusq
$filesetq
my $query = "
SELECT
- UNIX_TIMESTAMP($jobt.StartTime) AS starttime,
- Client.Name AS clientname,
- $jobt.Name AS jobname,
- $jobt.JobFiles AS jobfiles
-FROM $jobt, FileSet, Client $filter $groupf
-WHERE $jobt.ClientId = Client.ClientId
- AND $jobt.FileSetId = FileSet.FileSetId
- AND $jobt.Type = 'B'
+ UNIX_TIMESTAMP(Job.StartTime) AS starttime,
+ Client.Name AS clientname,
+ Job.Name AS jobname,
+ Job.JobFiles AS jobfiles
+FROM $jobt AS Job, FileSet, Client $filter $groupf
+WHERE Job.ClientId = Client.ClientId
+ AND Job.FileSetId = FileSet.FileSetId
+ AND Job.Type = 'B'
$clientq
$statusq
$filesetq
my $query = "
SELECT
- UNIX_TIMESTAMP($jobt.StartTime) AS starttime,
- Client.Name AS clientname,
- $jobt.Name AS jobname,
- $jobt.JobBytes /
+ UNIX_TIMESTAMP(Job.StartTime) AS starttime,
+ Client.Name AS clientname,
+ Job.Name AS jobname,
+ Job.JobBytes /
($bweb->{sql}->{SEC_TO_INT}(
$bweb->{sql}->{UNIX_TIMESTAMP}(EndTime)
- $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime)) + 0.01)
AS rate
-FROM $jobt, FileSet, Client $filter $groupf
-WHERE $jobt.ClientId = Client.ClientId
- AND $jobt.FileSetId = FileSet.FileSetId
- AND $jobt.Type = 'B'
+FROM $jobt AS Job, FileSet, Client $filter $groupf
+WHERE Job.ClientId = Client.ClientId
+ AND Job.FileSetId = FileSet.FileSetId
+ AND Job.Type = 'B'
$clientq
$statusq
$filesetq
my $query = "
SELECT
- UNIX_TIMESTAMP($jobt.StartTime) AS starttime,
- Client.Name AS clientname,
- $jobt.Name AS jobname,
+ UNIX_TIMESTAMP(Job.StartTime) AS starttime,
+ Client.Name AS clientname,
+ Job.Name AS jobname,
$bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime)
- $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime))
AS duration
-FROM $jobt, FileSet, Client $filter $groupf
-WHERE $jobt.ClientId = Client.ClientId
- AND $jobt.FileSetId = FileSet.FileSetId
- AND $jobt.Type = 'B'
+FROM $jobt AS Job, FileSet, Client $filter $groupf
+WHERE Job.ClientId = Client.ClientId
+ AND Job.FileSetId = FileSet.FileSetId
+ AND Job.Type = 'B'
$clientq
$statusq
$filesetq
}
my $stime = $bweb->{sql}->{"STARTTIME_$d"};
- $stime =~ s/Job\./$jobt\./;
my $query = "
SELECT
" . ($per_t?"":"UNIX_TIMESTAMP") . "($stime) AS A,
$t(JobBytes) AS nb
-FROM $jobt, FileSet, Client $filter $groupf
-WHERE $jobt.ClientId = Client.ClientId
- AND $jobt.FileSetId = FileSet.FileSetId
- AND $jobt.Type = 'B'
+FROM $jobt AS Job, FileSet, Client $filter $groupf
+WHERE Job.ClientId = Client.ClientId
+ AND Job.FileSetId = FileSet.FileSetId
+ AND Job.Type = 'B'
$clientq
$statusq
$filesetq
return $1 * $mult;
}
+# get long term statistic table
+sub get_stat_table
+{
+ my ($self) = @_;
+ my $ret = $self->{info}->{stat_job_table} || 'Job';
+ if ($ret !~ m/^job$/i) {
+ $ret = "(SELECT * FROM Job UNION SELECT * FROM $ret)";
+ }
+ return $ret;
+}
sub connect_db
{
$self->can_do('r_group_mgnt');
my $arg = $self->get_form(qw/qclient_group jclients qnewgroup qcomment/);
+ if (!$arg->{qcomment}) {
+ $arg->{qcomment} = "''";
+ }
if (!$arg->{qclient_group} and $arg->{qnewgroup}) {
my $query = "
unless ($carg->{qclient_group}) {
return $self->error("Can't get group");
}
- my $jobt = $self->{info}->{stat_job_table} || 'Job';
+ my $jobt = $self->get_stat_table();
my ($limit, $label) = $self->get_limit(%arg);
my $query = "
$arg->{type}='day';
$type = 'DAY';
}
- my $jobt = $self->{info}->{stat_job_table} || 'Job';
+ my $jobt = $self->get_stat_table();
my $stime1 = $self->{sql}->{"STARTTIME_P" . $type}; # get 1,2,3
$stime1 =~ s/Job.StartTime/date/;
my $stime2 = $self->{sql}->{"STARTTIME_" . $type}; # get 2007-01-03, 2007-01-23