IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10131


Ignore:
Timestamp:
Nov 21, 2006, 6:28:12 PM (19 years ago)
Author:
jhoblitt
Message:

SQL cleanup in pendingexpMode() & updateexpMode()
make -updateexp -exp_tag required

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/regtool.c

    r10116 r10131  
    8989
    9090    char *query =
    91         "SELECT newExp.*"
     91        "SELECT"
     92        "   newExp.*"
    9293        " FROM newExp"
    93         " LEFT JOIN newImfile USING(exp_tag)"
    94         " LEFT JOIN rawScienceExp USING(exp_tag)"
    95         " LEFT JOIN rawDetrendExp USING(exp_tag)"
     94        " LEFT JOIN newImfile"
     95        "   USING(exp_tag)"
     96        " LEFT JOIN rawScienceExp"
     97        "   USING(exp_tag)"
     98        " LEFT JOIN rawDetrendExp"
     99        "   USING(exp_tag)"
    96100        " WHERE"
    97         "   newExp.exp_tag IS NOT NULL"
    98         "   AND newImfile.exp_tag IS NULL"
     101        "   newImfile.exp_tag IS NULL"
    99102        "   AND rawScienceExp.exp_tag IS NULL"
     103        "   AND rawDetrendExp.exp_tag IS NULL"
    100104        "   AND newExp.imfiles ="
    101105        "   (SELECT COUNT(exp_tag) FROM rawImfile"
     
    131135
    132136    // negate simple so the default is true
    133     if (!ippdbPrintMetadatas(stdout, output, "newImfile", !simple)) {
     137    if (!ippdbPrintMetadatas(stdout, output, "p0PendingExp", !simple)) {
    134138        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    135139        psFree(output);
     
    209213    // exp_tag is not in newImfile
    210214    // that the correct count of imfiles is in rawImfile
    211 
    212     psString query = psStringCopy(
    213         "SELECT newExp.*"
     215   
     216    bool status = false;
     217    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     218    if (!status) {
     219        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
     220        return false;
     221    }
     222    if (!exp_tag) {
     223        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
     224        return false;
     225    }
     226
     227    bool detrend = psMetadataLookupBool(&status, config->args, "-detrend");
     228    if (!status) {
     229        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detrend");
     230        return false;
     231    }
     232
     233   char *query = psStringCopy(
     234        "SELECT"
     235        "   newExp.*"
    214236        " FROM newExp"
    215         " LEFT JOIN newImfile USING(exp_tag)"
    216         " LEFT JOIN rawScienceExp USING(exp_tag)"
    217         " LEFT JOIN rawDetrendExp USING(exp_tag)"
     237        " LEFT JOIN newImfile"
     238        "   USING(exp_tag)"
     239        " LEFT JOIN rawScienceExp"
     240        "   USING(exp_tag)"
     241        " LEFT JOIN rawDetrendExp"
     242        "   USING(exp_tag)"
    218243        " WHERE"
    219244        "   newExp.exp_tag IS NOT NULL"
     
    223248        "   (SELECT COUNT(exp_tag) FROM rawImfile"
    224249        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
     250        "   AND newExp.exp_tag = '%s'"
    225251        );
    226252
    227     {       
    228         bool status = false;
    229         psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
    230         if (!status) {
    231             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
    232             psFree(query);
    233             return false;
    234         }
    235         if (exp_tag) {
    236             psStringAppend(&query, " AND newExp.exp_tag = '%s'", exp_tag);
    237         }
    238     }
    239    
    240     if (!p_psDBRunQuery(config->dbh, query)) {
     253    if (!p_psDBRunQuery(config->dbh, query, exp_tag)) {
    241254        psError(PS_ERR_UNKNOWN, false, "database error");
    242         psFree(query);
    243         return false;
    244     }
    245     psFree(query);
     255        return false;
     256    }
    246257
    247258    psArray *output = p_psDBFetchResult(config->dbh);
     
    251262    }
    252263    if (!psArrayLength(output)) {
    253         // XXX check psError here
    254264        psError(PS_ERR_UNKNOWN, false, "no pending newExp rows found");
    255265        psFree(output);
    256         return false;
    257     }
    258 
    259     bool status = false;
    260     bool detrend = psMetadataLookupBool(&status, config->args, "-detrend");
    261     if (!status) {
    262         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detrend");
    263         return false;
    264     }
     266        return true;
     267    }
     268
    265269
    266270    // start a transaction so we don't end up with an exp in
  • trunk/ippTools/src/regtoolConfig.c

    r9764 r10131  
    7171    psMetadata *updateexpArgs = psMetadataAlloc();
    7272    psMetadataAddStr(updateexpArgs, PS_LIST_TAIL, "-exp_tag",  0,
    73         "exp_tag to operate on", NULL);
     73        "exp_tag to operate on (required)", NULL);
    7474    psMetadataAddStr(updateexpArgs, PS_LIST_TAIL, "-exp_type",  0,
    7575        "define exposure type", NULL);
Note: See TracChangeset for help on using the changeset viewer.