IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 12, 2009, 4:07:48 PM (17 years ago)
Author:
Paul Price
Message:

Reworking magic (and some diff) to be ready for performing magic on warp-warp diffs. Several database changes to diff and magic tables because we can no longer assume that a diff is associated with a single exposure. Ready for testing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_magic/ippTools/src/magictool.c

    r24136 r24149  
    131131    psMetadata *diffWhere = psMetadataAlloc(); // WHERE conditions for diffRuns
    132132    PXOPT_COPY_STR(config->args, diffWhere, "-diff_label", "diffRun.label", "==");
     133    PXOPT_COPY_S64(config->args, diffWhere, "-diff_id", "diff_id", "==");
    133134
    134135    psMetadata *queryWhere = psMetadataAlloc(); // WHERE conditions for everything else
     
    391392    // required
    392393    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
    393     PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);
    394394    PXOPT_LOOKUP_STR(node, config->args, "-node", true, false);
    395395
     
    397397            config->dbh,
    398398            magic_id,
    399             diff_id,
    400399            node
    401400    );
     
    612611    PS_ASSERT_PTR_NON_NULL(config, false);
    613612
    614     psMetadata *where = psMetadataAlloc();
    615     PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    616     PXOPT_COPY_STR(config->args, where, "-node", "node", "==");
     613    // Regrettably, there are multiple WHERE hooks which call the same things different names
     614    psMetadata *templatesWhere = psMetadataAlloc(); // WHERE for selecting template
     615    psMetadata *magicWhere = psMetadataAlloc();     // WHERE for selecting magic runs
     616    psMetadata *finalWhere = psMetadataAlloc();     // WHERE at end
     617
     618    PXOPT_COPY_S64(config->args, templatesWhere, "-magic_id", "magicRun.magic_id", "==");
     619    PXOPT_COPY_STR(config->args, templatesWhere, "-node", "diffInputSkyfile.skycell_id", "==");
     620
     621    PXOPT_COPY_S64(config->args, magicWhere, "-magic_id", "magicRun.magic_id", "==");
     622    PXOPT_COPY_STR(config->args, magicWhere, "-node", "magicTree.node", "==");
     623
     624    PXOPT_COPY_S64(config->args, finalWhere, "-magic_id", "magicRun.magic_id", "==");
     625    PXOPT_COPY_STR(config->args, finalWhere, "-node", "magicInputs.node", "==");
    617626
    618627    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     
    625634    }
    626635
    627     if (psListLength(where->list)) {
    628         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    629         psStringAppend(&query, " AND %s", whereClause);
     636    psString templatesWhereStr = psStringCopy(""); // WHERE for selecting template
     637    psString magicWhereStr = psStringCopy("");     // WHERE for selecting magic runs
     638
     639    if (psListLength(templatesWhere->list)) {
     640        psString whereClause = psDBGenerateWhereConditionSQL(templatesWhere, NULL);
     641        psStringAppend(&templatesWhereStr, "\nAND %s", whereClause);
    630642        psFree(whereClause);
    631643    }
    632     psFree(where);
     644    psFree(templatesWhere);
     645
     646    if (psListLength(magicWhere->list)) {
     647        psString whereClause = psDBGenerateWhereConditionSQL(magicWhere, NULL);
     648        psStringAppend(&magicWhereStr, "\nWHERE %s", whereClause);
     649        psFree(whereClause);
     650    }
     651    psFree(magicWhere);
     652
     653    if (psListLength(finalWhere->list)) {
     654        psString whereClause = psDBGenerateWhereConditionSQL(finalWhere, NULL);
     655        psStringAppend(&query, "\nWHERE %s", whereClause);
     656        psFree(whereClause);
     657    }
     658    psFree(finalWhere);
    633659
    634660    // treat limit == 0 as "no limit"
     
    639665    }
    640666
    641     if (!p_psDBRunQuery(config->dbh, query)) {
    642         psError(PS_ERR_UNKNOWN, false, "database error");
     667    if (!p_psDBRunQueryF(config->dbh, query,
     668                         templatesWhereStr, templatesWhereStr,
     669                         magicWhereStr, magicWhereStr)) {
     670        psError(PS_ERR_UNKNOWN, false, "database error");
     671        psFree(templatesWhereStr);
     672        psFree(magicWhereStr);
    643673        psFree(query);
    644674        return false;
    645675    }
     676    psFree(templatesWhereStr);
     677    psFree(magicWhereStr);
    646678    psFree(query);
    647679
     
    964996
    965997    // optional
    966     PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
     998    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
    967999
    9681000    // default values
     
    9721004                               magic_id,
    9731005                               node,
    974                                uri,
     1006                               path_base,
    9751007                               fault
    9761008        )) {
Note: See TracChangeset for help on using the changeset viewer.