Changeset 29991
- Timestamp:
- Dec 9, 2010, 8:57:01 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm
r29345 r29991 11 11 ########################################################################### 12 12 # 13 # Returns a list of batches that have been processed and loaded to datastore13 # Returns a list of batches created within the provided dates 14 14 # 15 15 ########################################################################### … … 39 39 $query->execute; 40 40 ${$batches} = $query->fetchall_arrayref(); 41 my $count = scalar @{${$batches}}; 42 43 return $count; 41 return scalar @{${$batches}}; 44 42 } 45 43 … … 72 70 $query->execute; 73 71 ${$batches} = $query->fetchall_arrayref(); 74 my $count = scalar @{${$batches}}; 75 76 return $count; 72 return scalar @{${$batches}}; 73 } 74 75 ########################################################################### 76 # 77 # Returns a count of all distinct exposures between provided limits 78 # 79 ########################################################################### 80 sub countExposures { 81 my ($self, $fromExp, $toExp, $datastoreProduct, $batchType, $dvoDb) = @_; 82 83 my $query = $self->{_db}->prepare(<<SQL); 84 SELECT COUNT(distinct exp_id) 85 FROM batches 86 WHERE exp_id >= $fromExp 87 AND exp_id <= $toExp 88 AND dvo_db = '$dvoDb' 89 AND batch_type = '$batchType' 90 AND datastore_product = '$datastoreProduct' 91 SQL 92 93 $query->execute; 94 return scalar $query->fetchrow_array(); 95 } 96 97 ########################################################################### 98 # 99 # Returns a count of exposures (between provided limits) that have been merged 100 # 101 ########################################################################### 102 sub countMergedExposures { 103 my ($self, $fromExp, $toExp, $datastoreProduct, $batchType, $dvoDb) = @_; 104 105 my $query = $self->{_db}->prepare(<<SQL); 106 SELECT COUNT(distinct exp_id) 107 FROM batches 108 WHERE exp_id >= $fromExp 109 AND exp_id <= $toExp 110 AND dvo_db = '$dvoDb' 111 AND batch_type = '$batchType' 112 AND datastore_product = '$datastoreProduct' 113 AND merged 114 SQL 115 116 $query->execute; 117 return scalar $query->fetchrow_array(); 118 } 119 120 ########################################################################### 121 # 122 # Returns a list of exposures (between provided limits) that have not been merged 123 # 124 ########################################################################### 125 sub getUnmergedExposures { 126 my ($self, $exposures, $fromExp, $toExp, $datastoreProduct, $batchType, $dvoDb) = @_; 127 128 my $query = $self->{_db}->prepare(<<SQL); 129 SELECT distinct exp_id 130 FROM batches 131 WHERE exp_id >= $fromExp 132 AND exp_id <= $toExp 133 AND dvo_db = '$dvoDb' 134 AND batch_type = '$batchType' 135 AND datastore_product = '$datastoreProduct' 136 AND !merged 137 SQL 138 139 $query->execute; 140 ${$exposures} = $query->fetchall_arrayref(); 141 return scalar @{${$exposures}}; 77 142 } 78 143 … … 166 231 ####################################################################################### 167 232 # 233 # Checks whether this exposure failed to load to the ODM 234 # 235 ######################################################################################## 236 sub didLoadFail { 237 my ($self, $expId) = @_; 238 239 my $query = $self->{_db}->prepare(<<SQL); 240 SELECT COUNT(*) 241 FROM batches 242 WHERE exp_id = $expId 243 AND load_failed 244 SQL 245 246 $query->execute; 247 248 return scalar $query->fetchrow_array(); 249 } 250 251 ####################################################################################### 252 # 253 # Checks whether this exposure has a min object ID under old PSPS hard limit of 72010000000000001 254 # 255 ######################################################################################## 256 sub isMinObjIdUnderLimit { 257 my ($self, $expId) = @_; 258 259 my $query = $self->{_db}->prepare(<<SQL); 260 SELECT COUNT(*) 261 FROM batches 262 WHERE exp_id = $expId 263 AND min_obj_id < 72010000000000001 264 SQL 265 266 $query->execute; 267 268 return scalar $query->fetchrow_array(); 269 } 270 ####################################################################################### 271 # 272 # Checks whether this exposure has been processed 273 # 274 ######################################################################################## 275 sub isExposureProcessed { 276 my ($self, $expId) = @_; 277 278 my $query = $self->{_db}->prepare(<<SQL); 279 SELECT COUNT(*) 280 FROM batches 281 WHERE exp_id = $expId 282 AND processed 283 SQL 284 285 $query->execute; 286 287 return scalar $query->fetchrow_array(); 288 } 289 290 ####################################################################################### 291 # 292 # Checks whether this exposure has been merged 293 # 294 ######################################################################################## 295 sub isExposureMerged { 296 my ($self, $expId) = @_; 297 298 my $query = $self->{_db}->prepare(<<SQL); 299 SELECT COUNT(*) 300 FROM batches 301 WHERE exp_id = $expId 302 AND merged 303 SQL 304 305 $query->execute; 306 307 return scalar $query->fetchrow_array(); 308 } 309 310 ####################################################################################### 311 # 312 # Checks whether this exposure has been loaded to ODM 313 # 314 ######################################################################################## 315 sub isExposureLoadedToOdm { 316 my ($self, $expId) = @_; 317 318 my $query = $self->{_db}->prepare(<<SQL); 319 SELECT COUNT(*) 320 FROM batches 321 WHERE exp_id = $expId 322 AND loaded_to_ODM 323 SQL 324 325 $query->execute; 326 327 return scalar $query->fetchrow_array(); 328 } 329 330 ####################################################################################### 331 # 168 332 # Checks whether we have successfully processed this exposure and loaded it to the datastore 169 333 # … … 184 348 my $processed = $query->fetchrow_array(); 185 349 350 # TODO can use return scalar $query->fetchrow_array(); 186 351 return $processed; 187 352 }
Note:
See TracChangeset
for help on using the changeset viewer.
