# HG changeset patch # User jbe # Date 1363595781 -3600 # Node ID e88d0606891f96f69bb09189df5d55c676b08e86 # Parent f65814f4d3fcc6e364125f6e9765baed9292dd86 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) diff -r f65814f4d3fc -r e88d0606891f core.sql --- a/core.sql Mon Mar 18 09:24:51 2013 +0100 +++ b/core.sql Mon Mar 18 09:36:21 2013 +0100 @@ -792,7 +792,7 @@ COMMENT ON COLUMN "suggestion"."plus1_fulfilled_count" IS 'Calculated from table "direct_supporter_snapshot", not requiring informed supporters'; COMMENT ON COLUMN "suggestion"."plus2_unfulfilled_count" IS 'Calculated from table "direct_supporter_snapshot", not requiring informed supporters'; COMMENT ON COLUMN "suggestion"."plus2_fulfilled_count" IS 'Calculated from table "direct_supporter_snapshot", not requiring informed supporters'; -COMMENT ON COLUMN "suggestion"."proportional_order" IS 'To be used for sorting suggestions within an initiative; updated by "lf_update_suggestion_order"'; +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"'; CREATE TABLE "rendered_suggestion" ( diff -r f65814f4d3fc -r e88d0606891f lf_update_suggestion_order.c --- a/lf_update_suggestion_order.c Mon Mar 18 09:24:51 2013 +0100 +++ b/lf_update_suggestion_order.c Mon Mar 18 09:36:21 2013 +0100 @@ -188,12 +188,12 @@ char *cmd; int i; if (final) { - 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) { + 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) { fprintf(stderr, "Could not prepare query string in memory.\n"); abort(); } } else { - if (asprintf(&cmd, "BEGIN; UPDATE \"suggestion\" SET \"proportional_order\" = 0 WHERE \"initiative_id\" = %s", escaped_initiative_id) < 0) { + if (asprintf(&cmd, "BEGIN; UPDATE \"suggestion\" SET \"proportional_order\" = NULL WHERE \"initiative_id\" = %s", escaped_initiative_id) < 0) { fprintf(stderr, "Could not prepare query string in memory.\n"); abort(); } diff -r f65814f4d3fc -r e88d0606891f update/core-update.v2.2.0-v2.2.1.sql --- a/update/core-update.v2.2.0-v2.2.1.sql Mon Mar 18 09:24:51 2013 +0100 +++ b/update/core-update.v2.2.0-v2.2.1.sql Mon Mar 18 09:36:21 2013 +0100 @@ -8,7 +8,7 @@ COMMENT ON COLUMN "initiative"."final_suggestion_order_calculated" IS 'Set to TRUE, when "proportional_order" of suggestions has been calculated the last time'; ALTER TABLE "suggestion" ADD COLUMN "proportional_order" INT4; -COMMENT ON COLUMN "suggestion"."proportional_order" IS 'To be used for sorting suggestions within an initiative; updated by "lf_update_suggestion_order"'; +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"'; CREATE VIEW "initiative_suggestion_order_calculation" AS SELECT