Changeset 28924
- Timestamp:
- Aug 16, 2010, 2:03:36 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/czartool/Gpc1Db.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czartool/Gpc1Db.pm
r28719 r28924 8 8 use czartool::MySQLDb; 9 9 our @ISA = qw(czartool::MySQLDb); # inherits from MySQLDb 10 11 ########################################################################### 12 # 13 # Returns the right join table and ID to join on for for a given stage TODO make private 14 # 15 ########################################################################### 16 sub getJoinTableAndId { 17 my ($self, $stage, $joinTable, $id) = @_; 18 19 ${$id} = $stage."_id"; 20 21 if ($stage eq "chip") {${$joinTable}="chipProcessedImfile";} 22 elsif ($stage eq "cam") {${$joinTable}="camProcessedExp";} 23 elsif ($stage eq "fake") {${$joinTable}="fakeProcessedImfile";} 24 elsif ($stage eq "warp") {${$joinTable}="warpSkyfile";} 25 elsif ($stage eq "stack") {${$joinTable}="stackSumSkyfile";} 26 elsif ($stage eq "diff") {${$joinTable}="diffSkyfile";} 27 elsif ($stage eq "magic") {${$joinTable}="magicNodeResult";} 28 elsif ($stage eq "magicDS") {${$id} = "magic_ds_id"; ${$joinTable}="magicDSFile";} 29 elsif ($stage eq "dist") {${$joinTable}="distComponent";} 30 else { 31 32 print "* ERROR: could nod find joinTable and ID for '$stage' stage\n"; 33 return 0; 34 } 35 36 return 1; 37 } 10 38 11 39 ########################################################################### … … 30 58 } 31 59 32 33 60 ########################################################################### 34 61 # … … 37 64 ########################################################################### 38 65 sub countFaults { 39 my ($self, $label, $stage ) = @_;66 my ($self, $label, $stage, $state) = @_; 40 67 41 42 my $table = getTableForStage($self, $stage); 43 my $joinTable; 44 my $id = $stage."_id"; 45 46 if ($stage eq "chip") {$joinTable="chipProcessedImfile";} 47 elsif ($stage eq "cam") {$joinTable="camProcessedExp";} 48 elsif ($stage eq "fake") {$joinTable="fakeProcessedImfile";} 49 elsif ($stage eq "warp") {$joinTable="warpSkyfile";} 50 elsif ($stage eq "stack") {$joinTable="stackSumSkyfile";} 51 elsif ($stage eq "diff") {$joinTable="diffSkyfile";} 52 elsif ($stage eq "magic") {$joinTable="magicNodeResult";} 53 elsif ($stage eq "magicDS") {$id = "magic_ds_id"; $joinTable="magicDSFile";} 54 elsif ($stage eq "dist") {$joinTable="distComponent";} 55 else {return -1;} 68 my $table = undef; 69 my $joinTable = undef; 70 my $id = undef; 71 $table = getTableForStage($self, $stage); 72 if (!getJoinTableAndId($self, $stage, \$joinTable, \$id)) {return -1;} 56 73 57 74 my $faultCol = $joinTable.".fault"; … … 64 81 WHERE label LIKE '$label' 65 82 AND $faultCol != 0 66 AND $stateCol = ' new'83 AND $stateCol = '$state' 67 84 SQL 68 85 … … 85 102 SQL 86 103 87 $query->execute;104 $query->execute; 88 105 my $priority = scalar $query->fetchrow_array(); 89 106 if (!$priority) {return 50000;} # assume labels not given priority in gpc1 Db have highest priority … … 100 117 101 118 my $table = getTableForStage($self, $stage); 102 if ($state eq "fault") {return countFaults($stage);} 119 my $query = undef; 120 121 if ($state eq "update") { 122 123 if ($stage eq "dist") {return 0;} 124 my $joinTable = undef; 125 my $id = undef; 126 if (!getJoinTableAndId($self, $stage, \$joinTable, \$id)) {return -1;} 127 128 if ($stage eq "chip" || $stage eq "fake" || $stage eq "warp" || $stage eq "diff" || $stage eq "magicDS") { 129 $query = $self->{_db}->prepare(<<SQL); 130 SELECT COUNT(state) 131 FROM $table JOIN $joinTable 132 USING($id) 133 WHERE label LIKE '$label' 134 AND state = 'update' 135 AND data_state = 'update'; 136 SQL 137 } 138 else { 139 140 $query = $self->{_db}->prepare(<<SQL); 141 SELECT COUNT(state) 142 FROM $table JOIN $joinTable 143 USING($id) 144 WHERE label LIKE '$label' 145 AND state = 'update'; 146 SQL 147 } 148 149 } 150 else { 151 152 $query = $self->{_db}->prepare(<<SQL); 153 SELECT COUNT(state) 154 FROM $table 155 WHERE label LIKE '$label' 156 AND state = '$state' 157 SQL 158 } 103 159 104 160 105 my $query = $self->{_db}->prepare(<<SQL); 106 SELECT count(state) 107 FROM $table 108 WHERE label LIKE '$label' 109 AND state = '$state' 110 SQL 111 112 $query->execute; 161 $query->execute; 113 162 return scalar $query->fetchrow_array(); 114 163 }
Note:
See TracChangeset
for help on using the changeset viewer.
