commit 65df883
default
·
2023-08-08 11:56:12 +0000 UTC
parent 4318e8f
Fixed votersCount.
1 files changed,
+7,
-2
+7,
-2
1@@ -1257,7 +1257,6 @@ int update_question(snac *user, const char *id)
2 xs *msg = NULL;
3 xs *rcnt = xs_dict_new();
4 xs *z = xs_number_new(0);
5- xs *rcpts = xs_list_new();
6 xs *lopts = xs_list_new();
7 xs_list *opts;
8 xs_list *p;
9@@ -1286,6 +1285,9 @@ int update_question(snac *user, const char *id)
10 }
11 }
12
13+ xs_set s;
14+ xs_set_init(&s);
15+
16 /* iterate now the children (the votes) */
17 xs *chld = object_children(id);
18 p = chld;
19@@ -1307,11 +1309,13 @@ int update_question(snac *user, const char *id)
20 xs *ucnt = xs_number_new(xs_number_get(cnt) + 1);
21 rcnt = xs_dict_set(rcnt, name, ucnt);
22
23- rcpts = xs_list_append(rcpts, atto);
24+ xs_set_add(&s, atto);
25 }
26 }
27 }
28
29+ xs *rcpts = xs_set_result(&s);
30+
31 /* create a new list of options with their new counts */
32 xs *nopts = xs_list_new();
33 p = lopts;
34@@ -1354,6 +1358,7 @@ int update_question(snac *user, const char *id)
35 /* update the count of voters */
36 xs *vcnt = xs_number_new(xs_list_len(rcpts));
37 msg = xs_dict_set(msg, "votersCount", vcnt);
38+ msg = xs_dict_set(msg, "cc", rcpts);
39
40 /* store */
41 object_add_ow(id, msg);