IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25929


Ignore:
Timestamp:
Oct 22, 2009, 4:51:58 PM (17 years ago)
Author:
Paul Price
Message:

Giving publishClient an 'active' column, and add mode to pubtool to turn this on and off. Only interested in active clients. This is so that I can do a publishing run that only sends data to particular clients.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/dbconfig/changes.txt

    r25913 r25929  
    14221422-- Vesion 1.1.57
    14231423
    1424 -- add changes for 1.1.57 here. Then uncomment the following before commiting
     1424ALTER TABLE publishClient ADD COLUMN active TINYINT DEFAULT 0 AFTER client_id;
     1425
     1426
    14251427
    14261428-- UPDATE dbversion set schema_version = '1.1.57',  updated= CURRENT_TIMESTAMP();
  • trunk/dbconfig/publish.md

    r25256 r25929  
    33publishClient    METADATA
    44    client_id    S64         0       # Primary Key AUTO_INCREMENT
     5    active       BOOL        TRUE
    56    product      STR         64
    67    stage        STR         64
  • trunk/ippTools/share/pubtool_definerun.sql

    r24512 r25929  
    1111    JOIN diffRun
    1212    WHERE publishClient.stage = 'diff'
     13        AND publishClient.active = 1
    1314        AND diffRun.state = 'full'
    1415    -- WHERE hook %s
     
    2122    JOIN camRun
    2223    WHERE publishClient.stage = 'camera'
     24        AND publishClient.active = 1
    2325        AND camRun.state = 'full'
    2426    -- WHERE hook %s
  • trunk/ippTools/share/pubtool_pending.sql

    r24707 r25929  
    2424    JOIN rawExp USING(exp_id)
    2525    WHERE publishClient.stage = 'diff'
     26        AND publishClient.active = 1
    2627        AND publishRun.state = 'new'
    2728        AND diffRun.state = 'full'
     
    4344    JOIN rawExp USING(exp_id)
    4445    WHERE publishClient.stage = 'camera'
     46        AND publishClient.active = 1
    4547        AND publishRun.state ='new'
    4648        AND camRun.state = 'full'
  • trunk/ippTools/share/pubtool_revert.sql

    r24512 r25929  
    33WHERE publishDone.pub_id = publishRun.pub_id
    44    AND publishRun.client_id = publishClient.client_id
     5    AND publishClient.active = 1
    56    AND publishDone.fault != 0
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r25913 r25929  
    14851485CREATE TABLE publishClient (
    14861486    client_id BIGINT AUTO_INCREMENT, -- unique identifier
     1487    active TINYINT DEFAULT 0,        -- whether we should worry about this or not
    14871488    product VARCHAR(64),             -- product name
    14881489    stage VARCHAR(64) NOT NULL, -- stage of interest (chip, camera, diff, etc.)
  • trunk/ippTools/src/pubtool.c

    r25256 r25929  
    3232
    3333static bool defineclientMode(pxConfig *config);
     34static bool updateclientMode(pxConfig *config);
    3435static bool definerunMode(pxConfig *config);
    3536static bool pendingMode(pxConfig *config);
     
    5758    switch (config->mode) {
    5859        MODECASE(PUBTOOL_MODE_DEFINECLIENT, defineclientMode);
     60        MODECASE(PUBTOOL_MODE_UPDATECLIENT, updateclientMode);
    5961        MODECASE(PUBTOOL_MODE_DEFINERUN, definerunMode);
    6062        MODECASE(PUBTOOL_MODE_PENDING, pendingMode);
     
    9496    PXOPT_LOOKUP_STR(comment, config->args, "-comment",  false, false);
    9597
    96     if (!publishClientInsert(config->dbh, 0, product, stage, workdir, comment)) {
    97         psError(PS_ERR_UNKNOWN, false, "Database error");
    98         return false;
    99     }
     98    if (!publishClientInsert(config->dbh, 0, 0, product, stage, workdir, comment)) {
     99        psError(PS_ERR_UNKNOWN, false, "Database error");
     100        return false;
     101    }
     102
     103    return true;
     104}
     105
     106static bool updateclientMode(pxConfig *config)
     107{
     108    PS_ASSERT_PTR_NON_NULL(config, false);
     109
     110    psMetadata *where = psMetadataAlloc(); // WHERE conditions
     111    PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "==");
     112    PXOPT_COPY_STR(config->args, where, "-product", "product", "==");
     113    PXOPT_COPY_STR(config->args, where, "-stage", "stage", "==");
     114    PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE");
     115
     116    PXOPT_LOOKUP_BOOL(active, config->args, "-active",  false);
     117    PXOPT_LOOKUP_BOOL(inactive, config->args, "-inactive",  false);
     118
     119    if ((!active && !inactive) || (active && inactive)) {
     120        psError(PS_ERR_UNKNOWN, false, "Must specify one, and only one, of -active and -inactive.");
     121        psFree(where);
     122        return false;
     123    }
     124
     125    psString query = NULL;              // Query to run
     126    psStringAppend(&query, "UPDATE publishRun SET active = %d", active ? 1 : 0);
     127
     128    if (psListLength(where->list)) {
     129        psString clause = psDBGenerateWhereConditionSQL(where, NULL);
     130        psStringAppend(&query, "\n AND %s", clause);
     131        psFree(clause);
     132    }
     133    psFree(where);
     134
     135    if (!p_psDBRunQuery(config->dbh, query)) {
     136        psError(PS_ERR_UNKNOWN, false, "Database error");
     137        psFree(query);
     138        return false;
     139    }
     140    psFree(query);
     141
     142    long numUpdated = psDBAffectedRows(config->dbh);
     143    psLogMsg("pubtool", PS_LOG_INFO, "%ld rows updated.", numUpdated);
    100144
    101145    return true;
  • trunk/ippTools/src/pubtool.h

    r24512 r25929  
    2626    PUBTOOL_MODE_NONE      = 0x0,
    2727    PUBTOOL_MODE_DEFINECLIENT,
     28    PUBTOOL_MODE_UPDATECLIENT,
    2829    PUBTOOL_MODE_DEFINERUN,
    2930    PUBTOOL_MODE_PENDING,
  • trunk/ippTools/src/pubtoolConfig.c

    r25256 r25929  
    5050    psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-comment", 0, "define comment", NULL);
    5151
     52    // -updateclient
     53    psMetadata *updateclientArgs = psMetadataAlloc();
     54    psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-client_id", 0, "search by client_id", NULL);
     55    psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-stage", 0, "search by stage", NULL);
     56    psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-product", 0, "search by product", NULL);
     57    psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-comment", 0, "search by comment (LIKE)", NULL);
     58    psMetadataAddBool(updateclientArgs, PS_LIST_TAIL, "-active", 0, "set to active state", NULL);
     59    psMetadataAddBool(updateclientArgs, PS_LIST_TAIL, "-inactive", 0, "set to inactive state", NULL);
     60
    5261    // -definerun
    5362    psMetadata *definerunArgs = psMetadataAlloc();
     
    8594
    8695    PXOPT_ADD_MODE("-defineclient", "", PUBTOOL_MODE_DEFINECLIENT, defineclientArgs);
     96    PXOPT_ADD_MODE("-updateclient", "", PUBTOOL_MODE_UPDATECLIENT, updateclientArgs);
    8797    PXOPT_ADD_MODE("-definerun", "", PUBTOOL_MODE_DEFINERUN, definerunArgs);
    8898    PXOPT_ADD_MODE("-pending", "", PUBTOOL_MODE_PENDING, pendingArgs);
Note: See TracChangeset for help on using the changeset viewer.