IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 14, 2010, 2:23:39 PM (16 years ago)
Author:
bills
Message:

fix tickeet 1198 add mode -revertcleanup to revert errors that occur when cleaning (or purging or scrubbing)

File:
1 edited

Legend:

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

    r29365 r29416  
    4848static bool pendingcleanuprunMode(pxConfig *config);
    4949static bool pendingcleanupskyfileMode(pxConfig *config);
     50static bool revertcleanupMode(pxConfig *config);
    5051static bool donecleanupMode(pxConfig *config);
    5152static bool updatediffskyfileMode(pxConfig *config);
     
    100101        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
    101102        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode);
     103        MODECASE(DIFFTOOL_MODE_REVERTCLEANUP,         revertcleanupMode);
    102104        MODECASE(DIFFTOOL_MODE_DONECLEANUP,           donecleanupMode);
    103105        MODECASE(DIFFTOOL_MODE_UPDATEDIFFSKYFILE,     updatediffskyfileMode);
     
    25312533
    25322534
     2535static bool revertcleanupMode(pxConfig *config)
     2536{
     2537    PS_ASSERT_PTR_NON_NULL(config, false);
     2538
     2539    psMetadata *where = psMetadataAlloc();
     2540    PXOPT_COPY_S64(config->args, where, "-diff_id",    "diffSkyfile.diff_id", "==");
     2541    pxAddLabelSearchArgs (config, where, "-label",     "diffRun.label", "LIKE");
     2542    pxAddLabelSearchArgs (config, where, "-data_group",   "diffRun.data_group", "LIKE");
     2543
     2544    PXOPT_LOOKUP_STR(state, config->args, "-state", false, false);
     2545
     2546    if (!psListLength(where->list)) {
     2547        psFree(where);
     2548        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
     2549        return false;
     2550    }
     2551    if (!state) {
     2552        state = "error_cleaned";
     2553    }
     2554    char *newState = NULL;
     2555    if (!strcmp(state, "error_cleaned")) {
     2556        newState = "goto_cleaned";
     2557    } else if (!strcmp(state, "error_purged")) {
     2558        newState = "goto_purged";
     2559    } else if (!strcmp(state, "error_scrubbed")) {
     2560        newState = "goto_scrubbed";
     2561    } else {
     2562        psError(PXTOOLS_ERR_CONFIG, true, "-state must be either error_cleaned, error_purged, or error_scrubbed");
     2563        return false;
     2564    }
     2565
     2566    psString query = pxDataGet("difftool_revertcleanup.sql");
     2567    if (!query) {
     2568        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     2569        return false;
     2570    }
     2571
     2572    if (psListLength(where->list)) {
     2573        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     2574        psStringAppend(&query, " AND %s", whereClause);
     2575        psFree(whereClause);
     2576    }
     2577    psFree(where);
     2578
     2579    if (!p_psDBRunQueryF(config->dbh, query, newState, state, state)) {
     2580        psError(PS_ERR_UNKNOWN, false, "database error");
     2581        psFree(query);
     2582        return false;
     2583    }
     2584    psFree(query);
     2585
     2586    int numDeleted = psDBAffectedRows(config->dbh);
     2587
     2588    psLogMsg("difftool", PS_LOG_INFO, "Reverted %d diffRuns and diffSkyfiles", numDeleted);
     2589
     2590    return true;
     2591}
    25332592static bool donecleanupMode(pxConfig *config)
    25342593{
Note: See TracChangeset for help on using the changeset viewer.