annotate app/main/api/_issue.lua @ 1641:ab837b075cf7
Fixed mldap_get_named_number_arg to not leave any element on the Lua stack (should not have had any effect anyway but is now consistent to documentation)
| author |
jbe |
| date |
Tue Feb 09 17:44:47 2021 +0100 (2021-02-09) |
| parents |
32cc544d5a5b |
| children |
|
| rev |
line source |
|
bsw/jbe@1309
|
1 local issues = param.get("issues", "table")
|
|
bsw/jbe@1309
|
2
|
|
bsw/jbe@1309
|
3
|
|
bsw/jbe@1309
|
4 local fields = { "id", "area_id", "policy_id", "admin_notice", "external_reference", "state", "phase_finished", "created", "accepted", "half_frozen", "fully_frozen", "closed", "cleaned", "min_admission_time", "max_admission_time", "discussion_time", "verification_time", "voting_time", "latest_snapshot_id", "admission_snapshot_id", "half_freeze_snapshot_id", "full_freeze_snapshot_id", "population", "voter_count", "status_quo_schulze_rank" }
|
|
bsw/jbe@1309
|
5
|
|
bsw/jbe@1309
|
6 local r = json.array()
|
|
bsw/jbe@1309
|
7
|
|
bsw/jbe@1309
|
8 for i, issue in ipairs(issues) do
|
|
bsw/jbe@1309
|
9 local ir = json.object()
|
|
bsw/jbe@1309
|
10 for j, field in ipairs(fields) do
|
|
bsw/jbe@1309
|
11 local value = issue[field]
|
|
bsw/jbe@1309
|
12 if value == nil then
|
|
bsw/jbe@1309
|
13 value = json.null
|
|
bsw/jbe@1309
|
14 else
|
|
bsw/jbe@1309
|
15 value = tostring(value)
|
|
bsw/jbe@1309
|
16 end
|
|
bsw/jbe@1309
|
17 ir[field] = value
|
|
bsw/jbe@1309
|
18 end
|
|
bsw/jbe@1309
|
19 r[#r+1] = ir
|
|
bsw/jbe@1309
|
20 end
|
|
bsw/jbe@1309
|
21
|
|
bsw/jbe@1309
|
22 return r
|