IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 21, 2009, 2:49:37 PM (17 years ago)
Author:
bills
Message:

Detect the completion and state updates of a magicDSRun in a new advance task.

File:
1 edited

Legend:

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

    r25423 r25465  
    3737static bool todestreakMode(pxConfig *config);
    3838static bool adddestreakedfileMode(pxConfig *config);
     39static bool advancerunMode(pxConfig *config);
    3940static bool revertdestreakedfileMode(pxConfig *config);
    4041static bool getskycellsMode(pxConfig *config);
     
    4445
    4546static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state);
    46 static bool magicDSRunComplete(pxConfig *config, bool setmagicked);
    4747static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id);
    4848
     
    7070        MODECASE(MAGICDSTOOL_MODE_TODESTREAK,          todestreakMode);
    7171        MODECASE(MAGICDSTOOL_MODE_ADDDESTREAKEDFILE,   adddestreakedfileMode);
     72        MODECASE(MAGICDSTOOL_MODE_ADVANCERUN,          advancerunMode);
    7273        MODECASE(MAGICDSTOOL_MODE_REVERTDESTREAKEDFILE,revertdestreakedfileMode);
    7374        MODECASE(MAGICDSTOOL_MODE_GETSKYCELLS,         getskycellsMode);
     
    119120    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
    120121    PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "==");
    121     PXOPT_COPY_S64(config->args, where, "-magic_id","magic_id", "==");
     122    PXOPT_COPY_S64(config->args, where, "-magic_id","magicRun.magic_id", "==");
    122123    PXOPT_COPY_S32(config->args, where, "-streaks_max","streaks", "<=");
    123124
     
    661662    }
    662663
    663     if (!magicDSRunComplete(config, setmagicked)) {
    664             // rollback
    665         if (!psDBRollback(config->dbh)) {
    666             psError(PS_ERR_UNKNOWN, false, "database error");
    667         }
    668         psError(PS_ERR_UNKNOWN, false, "database error");
    669         return false;
    670     }
    671 
    672664    if (!psDBCommit(config->dbh)) {
    673665        psError(PS_ERR_UNKNOWN, false, "database error");
     
    743735}
    744736
    745 static bool magicDSRunComplete(pxConfig *config, bool setmagicked)
     737static bool advancerunMode(pxConfig *config)
    746738{
    747739    PS_ASSERT_PTR_NON_NULL(config, false);
     740
     741    psMetadata *where = psMetadataAlloc();
     742    PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magicDSRun.magic_ds_id", "==");
     743    pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "==");
     744
     745    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    748746
    749747    // look for completed magicDSRuns
     
    754752    }
    755753
     754    if (psListLength(where->list)) {
     755        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     756        psStringAppend(&query, " WHERE %s", whereClause);
     757        psFree(whereClause);
     758    }
     759
    756760    if (!p_psDBRunQuery(config->dbh, query)) {
    757761        psError(PS_ERR_UNKNOWN, false, "database error");
     
    771775        return true;
    772776    }
     777    if (!psDBTransaction(config->dbh)) {
     778        psError(PS_ERR_UNKNOWN, false, "database error");
     779        return false;
     780    }
    773781    for (long i = 0; i < psArrayLength(output); i++) {
    774782        psMetadata *row = output->data[i];
     
    776784        psS64 magic_ds_id = psMetadataLookupS64(NULL, row, "magic_ds_id");
    777785
    778         // if requested, set stageRun.magicked
     786        // if re_place, set stageRun.magicked
     787        bool setmagicked = psMetadataLookupBool(NULL, row, "re_place");
    779788        if (setmagicked && !setRunMagicked(config, magic_ds_id)) {
    780789            psError(PS_ERR_UNKNOWN, false, "failed to change stageRun.magicked for magic_ds_id: %" PRId64,
    781790                magic_ds_id);
     791            if (!psDBRollback(config->dbh)) {
     792                psError(PS_ERR_UNKNOWN, false, "database error");
     793            }
    782794            return false;
    783795        }
     
    788800                magic_ds_id);
    789801            psFree(output);
     802            if (!psDBRollback(config->dbh)) {
     803                psError(PS_ERR_UNKNOWN, false, "database error");
     804            }
    790805            return false;
    791806        }
    792807    }
    793 
     808    if (!psDBCommit(config->dbh)) {
     809        psError(PS_ERR_UNKNOWN, false, "database error");
     810        return false;
     811    }
    794812
    795813    return true;
     
    833851    return true;
    834852}
     853
    835854static bool completedrevertMode(pxConfig *config)
    836855{
Note: See TracChangeset for help on using the changeset viewer.