IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 27, 2013, 2:09:24 PM (13 years ago)
Author:
bills
Message:

add mode -summary to releasetool which lists stackSummaries associated with
released stacks

File:
1 edited

Legend:

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

    r35897 r36041  
    4747static bool updaterelstackMode(pxConfig *config);
    4848static bool listrelstackMode(pxConfig *config);
     49static bool summaryMode(pxConfig *config);
    4950static bool definerelgroupMode(pxConfig *config);
    5051static bool pendingrelgroupMode(pxConfig *config);
     
    8485        MODECASE(RELEASETOOL_MODE_UPDATERELSTACK,   updaterelstackMode);
    8586        MODECASE(RELEASETOOL_MODE_LISTRELSTACK,     listrelstackMode);
     87        MODECASE(RELEASETOOL_MODE_SUMMARY,          summaryMode);
    8688
    8789        MODECASE(RELEASETOOL_MODE_DEFINERELGROUP,   definerelgroupMode);
     
    10781080
    10791081    if (priority_order) {
    1080         psStringAppend(&query, "\nAND priority > 0 order by stack_id, priority DESC");
     1082        psStringAppend(&query, "\nAND priority > 0 order by priority DESC, stack_id");
     1083    }
     1084
     1085    if (limit) {
     1086        psString limitString = psDBGenerateLimitSQL(limit);
     1087        psStringAppend(&query, " %s", limitString);
     1088        psFree(limitString);
     1089    }
     1090
     1091    if (!p_psDBRunQuery(config->dbh, query)) {
     1092        psError(PS_ERR_UNKNOWN, false, "database error");
     1093        psFree(query);
     1094        return false;
     1095    }
     1096    psFree(query);
     1097
     1098    psArray *output = p_psDBFetchResult(config->dbh);
     1099    if (!output) {
     1100        psError(PS_ERR_UNKNOWN, false, "database error");
     1101        return false;
     1102    }
     1103
     1104    if (!psArrayLength(output)) {
     1105        psTrace("releasetool", PS_LOG_INFO, "no rows found");
     1106        psFree(output);
     1107        return true;
     1108    }
     1109
     1110    if (!ippdbPrintMetadatas(stdout, output, "relStack", !simple)) {
     1111        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1112        psFree(output);
     1113        return false;
     1114    }
     1115
     1116    psFree(output);
     1117
     1118    return true;
     1119}
     1120static bool summaryMode(pxConfig *config)
     1121{
     1122    PS_ASSERT_PTR_NON_NULL(config, NULL);
     1123
     1124    psMetadata *where = psMetadataAlloc();
     1125
     1126    PXOPT_COPY_S64(config->args, where, "-sass_id",     "stackAssociation.sass_id", "==");
     1127    PXOPT_COPY_S64(config->args, where, "-relstack_id", "relStack.relstack_id", "==");
     1128    PXOPT_COPY_S64(config->args, where, "-stack_id",    "relStack.stack_id", "==");
     1129//    PXOPT_COPY_S64(config->args, where, "-skycal_id",   "relStack.skycal_id", "==");
     1130    PXOPT_COPY_S64(config->args, where, "-relstack_id", "relStack.relstack_id", "==");
     1131    PXOPT_COPY_STR(config->args, where, "-release_name", "ippRelease.release_name", "LIKE");
     1132    pxAddLabelSearchArgs(config, where, "-release_state","ippRelease.state", "==");
     1133//    PXOPT_COPY_STR(config->args, where, "-state",       "relStack.state", "==");
     1134    PXOPT_COPY_STR(config->args, where, "-filter",      "relStack.filter", "LIKE");
     1135//    PXOPT_COPY_F32(config->args, where, "-mjd_min",    "stackSumSkyfile.mjd_obs", ">=");
     1136//    PXOPT_COPY_F32(config->args, where, "-mjd_max",    "stackSumSkyfile.mjd_obs", "<=");
     1137    PXOPT_COPY_STR(config->args, where, "-tess_id",     "relStack.tess_id", "==");
     1138    PXOPT_COPY_STR(config->args, where, "-skycell_id",  "relStack.skycell_id", "LIKE");
     1139    PXOPT_COPY_STR(config->args, where, "-projection_cell",  "stackAssociation.projection_cell", "LIKE");
     1140    PXOPT_COPY_STR(config->args, where, "-stack_data_group",  "stackRun.data_group", "LIKE");
     1141//    PXOPT_COPY_STR(config->args, where, "-skycal_data_group", "skycalRun.data_group", "LIKE");
     1142
     1143    PXOPT_COPY_STR(config->args, where, "-surveyName",  "survey.surveyName", "LIKE");
     1144    PXOPT_COPY_S32(config->args, where, "-rel_id",      "relExp.rel_id", "==");
     1145    pxskycellAddWhere(config, where);
     1146
     1147//    PXOPT_COPY_F32(config->args, where, "-fwhm_min",    "IFNULL(skycalResult.fwhm_major, 999)", ">=");
     1148//    PXOPT_COPY_F32(config->args, where, "-fwhm_max",    "IFNULL(skycalResult.fwhm_major, 0)", "<=");
     1149
     1150    PXOPT_LOOKUP_BOOL(priority_order, config->args, "-priority_order", false);
     1151
     1152    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1153    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1154
     1155    pxAddLabelSearchArgs (config, where, "-stack_type", "relStack.stack_type", "==");
     1156
     1157    psString query = pxDataGet("releasetool_summary.sql");
     1158    if (!query) {
     1159        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1160        return false;
     1161    }
     1162
     1163    if (psListLength(where->list)) {
     1164        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1165        psStringAppend(&query, "\nWHERE %s", whereClause);
     1166        psFree(whereClause);
     1167    } else {
     1168        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required\n");
     1169        psFree(where);
     1170        return false;
     1171    }
     1172
     1173    if (priority_order) {
     1174        psStringAppend(&query, "\nAND priority > 0 order by priority DESC, stack_id");
    10811175    }
    10821176
Note: See TracChangeset for help on using the changeset viewer.