IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 10:30:59 AM (18 years ago)
Author:
eugene
Message:

completely deprecate config->where; make all command-line handling consistent; move nearly all sql into share/*.sql; ensure consistency between args supplied and used

File:
1 edited

Legend:

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

    r18336 r18561  
    9292    PS_ASSERT_PTR_NON_NULL(config, false);
    9393
    94     PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
    95 
    9694    psMetadata *where = psMetadataAlloc();
    97     // convert exp_id into a psS64
    98     if (exp_id) {
    99         if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) {
    100             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    101             psFree(where);
    102             return false;
    103         }
    104     }
    105 
     95
     96    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    10697    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
    10798    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
     
    110101    PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
    111102    PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "==");
     103    PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "==");
    112104    PXOPT_COPY_STR(config->args, where, "-filelevel", "filelvel", "==");
    113105    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
    114106    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
    115     PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
    116     PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
     107    PXOPT_COPY_F32(config->args, where, "-airmass_min", "airmass", ">=");
     108    PXOPT_COPY_F32(config->args, where, "-airmass_max", "airmass", "<");
    117109    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
    118110    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
     
    157149    PXOPT_LOOKUP_STR(region, config->args, "-set_region", false, false);
    158150
    159     // default
    160     PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "==");
    161 
    162151    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
    163152    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    324313
    325314    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     315    PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false);
    326316
    327317    // create a temp table to hold completely processed chipRuns
    328 {
    329     psString query = pxDataGet("flatcorr_create_tmp_chiprundone.sql");
    330     if (!query) {
    331         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    332         return false;
    333     }
    334 
    335     if (!p_psDBRunQuery(config->dbh, query)) {
    336         psError(PS_ERR_UNKNOWN, false, "database error");
    337         psFree(query);
    338         return false;
    339     }
    340 
    341     psFree(query);
    342 }
    343 
     318    {
     319        psString query = pxDataGet("flatcorr_create_tmp_chiprundone.sql");
     320        if (!query) {
     321            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     322            return false;
     323        }
     324
     325        if (!p_psDBRunQuery(config->dbh, query)) {
     326            psError(PS_ERR_UNKNOWN, false, "database error");
     327            psFree(query);
     328            return false;
     329        }
     330
     331        psFree(query);
     332    }
    344333   
    345334    // find all completed chipRuns
    346 {
    347     psString query = pxDataGet("flatcorr_completely_processed_chiprun.sql");
    348     if (!query) {
    349         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    350         return false;
    351     }
    352 
    353     if (!p_psDBRunQuery(config->dbh, query)) {
    354         psError(PS_ERR_UNKNOWN, false, "database error");
    355         psFree(query);
    356         return false;
    357     }
    358 
    359     psFree(query);
    360 }
     335    {
     336        psString query = pxDataGet("flatcorr_completely_processed_chiprun.sql");
     337        if (!query) {
     338            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     339            return false;
     340        }
     341
     342        if (!p_psDBRunQuery(config->dbh, query)) {
     343            psError(PS_ERR_UNKNOWN, false, "database error");
     344            psFree(query);
     345            return false;
     346        }
     347
     348        psFree(query);
     349    }
     350
    361351    // find flatcorrRun's that have had all of their chipRun's completed by
    362352    // comparing against the temp table
     
    367357    }
    368358
     359    // treat limit == 0 as "no limit"
     360    if (limit) {
     361        psString limitString = psDBGenerateLimitSQL(limit);
     362        psStringAppend(&query, " %s", limitString);
     363        psFree(limitString);
     364    }
     365
    369366    if (!p_psDBRunQuery(config->dbh, query)) {
    370367        psError(PS_ERR_UNKNOWN, false, "database error");
     
    377374        psErrorCode err = psErrorCodeLast();
    378375        switch (err) {
    379             case PS_ERR_DB_CLIENT:
    380                 psError(PXTOOLS_ERR_SYS, false, "database error");
    381             case PS_ERR_DB_SERVER:
    382                 psError(PXTOOLS_ERR_PROG, false, "database error");
    383             default:
    384                 psError(PXTOOLS_ERR_PROG, false, "unknown error");
     376          case PS_ERR_DB_CLIENT:
     377            psError(PXTOOLS_ERR_SYS, false, "database error");
     378          case PS_ERR_DB_SERVER:
     379            psError(PXTOOLS_ERR_PROG, false, "database error");
     380          default:
     381            psError(PXTOOLS_ERR_PROG, false, "unknown error");
    385382        }
    386383
     
    412409    PS_ASSERT_PTR_NON_NULL(config, false);
    413410
     411    psMetadata *where = psMetadataAlloc();
     412    PXOPT_COPY_S64(config->args, where, "-corr_id", "corr_id", "==");
     413
    414414    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    415415    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    422422    }
    423423
    424     if (config->where) {
    425         psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
     424    if (psListLength(where->list)) {
     425        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    426426        psStringAppend(&query, " AND %s", whereClause);
    427427        psFree(whereClause);
    428428    }
     429    psFree(where);
    429430
    430431    // treat limit == 0 as "no limit"
Note: See TracChangeset for help on using the changeset viewer.