IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29991


Ignore:
Timestamp:
Dec 9, 2010, 8:57:01 AM (16 years ago)
Author:
rhenders
Message:

added numerous utility methods for use by new exposureSummary script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm

    r29345 r29991  
    1111###########################################################################
    1212#
    13 # Returns a list of batches that have been processed and loaded to datastore
     13# Returns a list of batches created within the provided dates
    1414#
    1515###########################################################################
     
    3939    $query->execute;
    4040    ${$batches} = $query->fetchall_arrayref();
    41     my $count = scalar @{${$batches}};
    42 
    43    return $count;
     41    return scalar @{${$batches}};
    4442}
    4543
     
    7270    $query->execute;
    7371    ${$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###########################################################################
     80sub 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'
     91SQL
     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###########################################################################
     102sub 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
     114SQL
     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###########################################################################
     125sub 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
     137SQL
     138
     139    $query->execute;
     140    ${$exposures} = $query->fetchall_arrayref();
     141    return scalar @{${$exposures}};
    77142}
    78143
     
    166231#######################################################################################
    167232#
     233# Checks whether this exposure failed to load to the ODM
     234#
     235########################################################################################
     236sub 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
     244SQL
     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########################################################################################
     256sub 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
     264SQL
     265
     266    $query->execute;
     267
     268    return scalar $query->fetchrow_array();
     269}
     270#######################################################################################
     271#
     272# Checks whether this exposure has been processed
     273#
     274########################################################################################
     275sub 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
     283SQL
     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########################################################################################
     295sub 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
     303SQL
     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########################################################################################
     315sub 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
     323SQL
     324
     325    $query->execute;
     326
     327    return scalar $query->fetchrow_array();
     328}
     329
     330#######################################################################################
     331#
    168332# Checks whether we have successfully processed this exposure and loaded it to the datastore
    169333#
     
    184348    my $processed = $query->fetchrow_array();
    185349
     350    # TODO can use return scalar $query->fetchrow_array();
    186351    return $processed;
    187352}
Note: See TracChangeset for help on using the changeset viewer.