IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19632


Ignore:
Timestamp:
Sep 21, 2008, 9:20:25 PM (18 years ago)
Author:
eugene
Message:

allow residimfile query for any state

Location:
trunk/ippTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/dettool_residimfile.sql

    r18561 r19632  
    99 JOIN rawExp
    1010   USING(exp_id)
    11  WHERE
  • trunk/ippTools/src/dettool_residimfile.c

    r19621 r19632  
    150150
    151151    psMetadata *where = psMetadataAlloc();
    152     PXOPT_COPY_S64(config->args, where, "-det_id",     "det_id", "==");
    153     PXOPT_COPY_S32(config->args, where, "-iteration",  "iteration", "==");
    154     PXOPT_COPY_S64(config->args, where, "-exp_id",     "exp_id", "==");
    155     PXOPT_COPY_STR(config->args, where, "-class_id",   "class_id", "==");
    156     PXOPT_COPY_STR(config->args, where, "-recip",      "recipe", "==");
     152    PXOPT_COPY_S64(config->args, where, "-det_id",       "detResidImfile.det_id", "==");
     153    PXOPT_COPY_S32(config->args, where, "-iteration",    "detResidImfile.iteration", "==");
     154    PXOPT_COPY_S64(config->args, where, "-exp_id",       "detResidImfile.exp_id", "==");
     155    PXOPT_COPY_STR(config->args, where, "-class_id",     "detResidImfile.class_id", "==");
     156    PXOPT_COPY_STR(config->args, where, "-recip",        "detResidImfile.recipe", "==");
     157    PXOPT_COPY_STR(config->args, where, "-select_state", "detRun.state", "==");
    157158
    158159    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     
    166167    }
    167168
    168     // NOTE: the query ends in a WHERE, add the required restriction on detRun.state
    169     char *value = NULL;
    170     bool status;
    171     if ((value = psMetadataLookupStr(&status, config->args, "-select_state"))) {
    172         psStringAppend(&query, " detRun.state = '%s'", value);
     169    bool hasWhere = false;
     170    if (psListLength(where->list)) {
     171        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     172        psStringAppend(&query, " %s", whereClause);
     173        psFree(whereClause);
     174        hasWhere = true;
     175    }
     176    psFree(where);
     177
     178    if (hasWhere) {
     179        psStringAppend(&query, " AND");
    173180    } else {
    174         psStringAppend(&query, " detRun.state = 'run'");
    175     }
    176 
    177     if (psListLength(where->list)) {
    178         psString whereClause = psDBGenerateWhereConditionSQL(where, "detResidImfile");
    179         psStringAppend(&query, " AND %s", whereClause);
    180         psFree(whereClause);
    181     }
    182     psFree(where);
     181        psStringAppend(&query, " WHERE");
     182    }
    183183
    184184    if (faulted) {
    185185        // list only faulted rows
    186         psStringAppend(&query, " %s", "AND detResidImfile.fault != 0");
     186        psStringAppend(&query, " %s", " detResidImfile.fault != 0");
    187187    } else {
    188188        // don't list faulted rows
    189         psStringAppend(&query, " %s", "AND detResidImfile.fault = 0");
     189        psStringAppend(&query, " %s", " detResidImfile.fault = 0");
    190190    }
    191191
Note: See TracChangeset for help on using the changeset viewer.