IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28896


Ignore:
Timestamp:
Aug 11, 2010, 12:11:13 PM (16 years ago)
Author:
rhenders
Message:

Added methods to for use with ODM-checking script

File:
1 edited

Legend:

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

    r28871 r28896  
    88use ippToPsps::MySQLDb;
    99our @ISA = qw(ippToPsps::MySQLDb);    # inherits from MySQLDb
     10
     11
     12###########################################################################
     13#
     14# Returns a list of batches that have been processed and loaded to datastore
     15#
     16###########################################################################
     17sub getBatchList {
     18    my ($self, $exposures) = @_;
     19
     20    my $query = $self->{_db}->prepare(<<SQL);
     21    SELECT exp_id, batch_id, survey_id
     22        FROM batches
     23        WHERE processed = 1
     24        AND on_datastore = 1
     25        AND created > '2010-08-10 12:03:40';
     26SQL
     27   
     28    # TODO remove date restriction
     29    $query->execute;
     30    ${$exposures} = $query->fetchall_arrayref();
     31    my $count = scalar @{${$exposures}};
     32
     33   printf( "* Found %d batch%s\n", $count, ($count==1) ? "" : "es");
     34   return $count;
     35}
     36
     37###########################################################################
     38#
     39# Returns a info about one particular batch
     40#
     41###########################################################################
     42sub getSingleBatch{
     43    my ($self, $batch_id, $exposures) = @_;
     44
     45    my $query = $self->{_db}->prepare(<<SQL);
     46    SELECT exp_id, batch_id, survey_id
     47        FROM batches
     48        WHERE batch_id = $batch_id
     49        AND processed = 1
     50        AND on_datastore = 1;
     51SQL
     52 
     53    $query->execute;
     54    ${$exposures} = $query->fetchall_arrayref();
     55    my $count = scalar @{${$exposures}};
     56
     57   printf( "* Found %d batch%s\n", $count, ($count==1) ? "" : "es");
     58   return $count;
     59}
    1060
    1161#######################################################################################
     
    137187    return $batchId;
    138188}
     189
     190#######################################################################################
     191#
     192# Updates an existing database record with info from ODM
     193#
     194#######################################################################################
     195sub updateODMStatus {
     196    my ($self,$batchId, $expId, $loadedToOdm, $mergeWorthy, $mergeCompleted) = @_;
     197
     198    my $query = $self->{_db}->prepare(<<SQL);
     199    UPDATE batches
     200        SET loaded_to_ODM = $loadedToOdm, merge_worthy = $mergeWorthy, merged = $mergeCompleted
     201        WHERE batch_id = $batchId
     202        AND exp_id = $expId;
     203SQL
     204
     205        $query->execute; # TODO check response of these
     206}
     207
     208
    139209
    140210###########################################################################
Note: See TracChangeset for help on using the changeset viewer.