liquid_feedback_core

changeset 404:c67971a3adaa

lf_update_issue_order.c: Insert "issue_order" rows for all issues in the area
author jbe
date Sun Oct 13 21:42:23 2013 +0200 (2013-10-13)
parents 236cabef04d2
children 9905a70a475f
files lf_update_issue_order.c
line diff
     1.1 --- a/lf_update_issue_order.c	Sun Oct 13 21:37:24 2013 +0200
     1.2 +++ b/lf_update_issue_order.c	Sun Oct 13 21:42:23 2013 +0200
     1.3 @@ -206,7 +206,7 @@
     1.4    PGresult *res;
     1.5    char *cmd;
     1.6    int i;
     1.7 -  if (asprintf(&cmd, "BEGIN; DELETE FROM \"issue_order\" USING \"issue\" WHERE \"issue_order\".\"id\" = \"issue\".\"id\" AND \"issue\".\"area_id\" = %s", escaped_area_id) < 0) {
     1.8 +  if (asprintf(&cmd, "BEGIN; DELETE FROM \"issue_order\" USING \"issue\" WHERE \"issue_order\".\"id\" = \"issue\".\"id\" AND \"issue\".\"area_id\" = %s; INSERT INTO \"issue_order\" (\"id\") SELECT \"id\" FROM \"issue\" WHERE \"area_id\" = %s", escaped_area_id, escaped_area_id) < 0) {
     1.9      fprintf(stderr, "Could not prepare query string in memory.\n");
    1.10      abort();
    1.11    }
    1.12 @@ -232,7 +232,7 @@
    1.13        fprintf(stderr, "Could not escape literal in memory.\n");
    1.14        abort();
    1.15      }
    1.16 -    if (asprintf(&cmd, "INSERT INTO \"issue_order\" (\"id\", \"order_in_admission_state\") VALUES (%s, %i)", escaped_issue_id, candidates[i].seat) < 0) {
    1.17 +    if (asprintf(&cmd, "UPDATE \"issue_order\" SET \"order_in_admission_state\" = %i WHERE \"id\" = %s", candidates[i].seat, escaped_issue_id) < 0) {
    1.18        fprintf(stderr, "Could not prepare query string in memory.\n");
    1.19        abort();
    1.20      }
    1.21 @@ -240,12 +240,12 @@
    1.22      res = PQexec(db, cmd);
    1.23      free(cmd);
    1.24      if (!res) {
    1.25 -      fprintf(stderr, "Error in pqlib while sending SQL command to insert issue order.\n");
    1.26 +      fprintf(stderr, "Error in pqlib while sending SQL command to update issue order in admission state.\n");
    1.27      } else if (
    1.28        PQresultStatus(res) != PGRES_COMMAND_OK &&
    1.29        PQresultStatus(res) != PGRES_TUPLES_OK
    1.30      ) {
    1.31 -      fprintf(stderr, "Error while executing SQL command to insert issue order:\n%s", PQresultErrorMessage(res));
    1.32 +      fprintf(stderr, "Error while executing SQL command to update issue order in admission state:\n%s", PQresultErrorMessage(res));
    1.33        PQclear(res);
    1.34      } else {
    1.35        PQclear(res);
    1.36 @@ -316,12 +316,12 @@
    1.37        res = PQexec(db, cmd);
    1.38        free(cmd);
    1.39        if (!res) {
    1.40 -        fprintf(stderr, "Error in pqlib while sending SQL command to update issue order.\n");
    1.41 +        fprintf(stderr, "Error in pqlib while sending SQL command to update issue order in open states.\n");
    1.42        } else if (
    1.43          PQresultStatus(res) != PGRES_COMMAND_OK &&
    1.44          PQresultStatus(res) != PGRES_TUPLES_OK
    1.45        ) {
    1.46 -        fprintf(stderr, "Error while executing SQL command to update issue order:\n%s", PQresultErrorMessage(res));
    1.47 +        fprintf(stderr, "Error while executing SQL command to update issue order in open states:\n%s", PQresultErrorMessage(res));
    1.48          PQclear(res);
    1.49        } else {
    1.50          PQclear(res);

Impressum / About Us