liquid_feedback_core

changeset 378:e88d0606891f

Bugfix regarding "proportional_order" of suggestions:
Use NULL values explicitly to be sorted last
(includes new suggestions as well as suggestions without any individual rankings)
author jbe
date Mon Mar 18 09:36:21 2013 +0100 (2013-03-18)
parents f65814f4d3fc
children 54e2a6e63a94
files core.sql lf_update_suggestion_order.c update/core-update.v2.2.0-v2.2.1.sql
line diff
     1.1 --- a/core.sql	Mon Mar 18 09:24:51 2013 +0100
     1.2 +++ b/core.sql	Mon Mar 18 09:36:21 2013 +0100
     1.3 @@ -792,7 +792,7 @@
     1.4  COMMENT ON COLUMN "suggestion"."plus1_fulfilled_count"    IS 'Calculated from table "direct_supporter_snapshot", not requiring informed supporters';
     1.5  COMMENT ON COLUMN "suggestion"."plus2_unfulfilled_count"  IS 'Calculated from table "direct_supporter_snapshot", not requiring informed supporters';
     1.6  COMMENT ON COLUMN "suggestion"."plus2_fulfilled_count"    IS 'Calculated from table "direct_supporter_snapshot", not requiring informed supporters';
     1.7 -COMMENT ON COLUMN "suggestion"."proportional_order"       IS 'To be used for sorting suggestions within an initiative; updated by "lf_update_suggestion_order"';
     1.8 +COMMENT ON COLUMN "suggestion"."proportional_order"       IS 'To be used for sorting suggestions within an initiative; NULL values sort last; updated by "lf_update_suggestion_order"';
     1.9  
    1.10  
    1.11  CREATE TABLE "rendered_suggestion" (
     2.1 --- a/lf_update_suggestion_order.c	Mon Mar 18 09:24:51 2013 +0100
     2.2 +++ b/lf_update_suggestion_order.c	Mon Mar 18 09:36:21 2013 +0100
     2.3 @@ -188,12 +188,12 @@
     2.4    char *cmd;
     2.5    int i;
     2.6    if (final) {
     2.7 -    if (asprintf(&cmd, "BEGIN; UPDATE \"initiative\" SET \"final_suggestion_order_calculated\" = TRUE WHERE \"id\" = %s; UPDATE \"suggestion\" SET \"proportional_order\" = 0 WHERE \"initiative_id\" = %s", escaped_initiative_id, escaped_initiative_id) < 0) {
     2.8 +    if (asprintf(&cmd, "BEGIN; UPDATE \"initiative\" SET \"final_suggestion_order_calculated\" = TRUE WHERE \"id\" = %s; UPDATE \"suggestion\" SET \"proportional_order\" = NULL WHERE \"initiative_id\" = %s", escaped_initiative_id, escaped_initiative_id) < 0) {
     2.9        fprintf(stderr, "Could not prepare query string in memory.\n");
    2.10        abort();
    2.11      }
    2.12    } else {
    2.13 -    if (asprintf(&cmd, "BEGIN; UPDATE \"suggestion\" SET \"proportional_order\" = 0 WHERE \"initiative_id\" = %s", escaped_initiative_id) < 0) {
    2.14 +    if (asprintf(&cmd, "BEGIN; UPDATE \"suggestion\" SET \"proportional_order\" = NULL WHERE \"initiative_id\" = %s", escaped_initiative_id) < 0) {
    2.15        fprintf(stderr, "Could not prepare query string in memory.\n");
    2.16        abort();
    2.17      }
     3.1 --- a/update/core-update.v2.2.0-v2.2.1.sql	Mon Mar 18 09:24:51 2013 +0100
     3.2 +++ b/update/core-update.v2.2.0-v2.2.1.sql	Mon Mar 18 09:36:21 2013 +0100
     3.3 @@ -8,7 +8,7 @@
     3.4  COMMENT ON COLUMN "initiative"."final_suggestion_order_calculated" IS 'Set to TRUE, when "proportional_order" of suggestions has been calculated the last time';
     3.5  
     3.6  ALTER TABLE "suggestion" ADD COLUMN "proportional_order" INT4;
     3.7 -COMMENT ON COLUMN "suggestion"."proportional_order" IS 'To be used for sorting suggestions within an initiative; updated by "lf_update_suggestion_order"';
     3.8 +COMMENT ON COLUMN "suggestion"."proportional_order" IS 'To be used for sorting suggestions within an initiative; NULL values sort last; updated by "lf_update_suggestion_order"';
     3.9  
    3.10  CREATE VIEW "initiative_suggestion_order_calculation" AS
    3.11    SELECT

Impressum / About Us