liquid_feedback_frontend
diff app/main/api/_issue.lua @ 1309:32cc544d5a5b
Cumulative patch for upcoming frontend version 4
author | bsw/jbe |
---|---|
date | Sun Jul 15 14:07:29 2018 +0200 (2018-07-15) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/api/_issue.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -0,0 +1,22 @@ 1.4 +local issues = param.get("issues", "table") 1.5 + 1.6 + 1.7 +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" } 1.8 + 1.9 +local r = json.array() 1.10 + 1.11 +for i, issue in ipairs(issues) do 1.12 + local ir = json.object() 1.13 + for j, field in ipairs(fields) do 1.14 + local value = issue[field] 1.15 + if value == nil then 1.16 + value = json.null 1.17 + else 1.18 + value = tostring(value) 1.19 + end 1.20 + ir[field] = value 1.21 + end 1.22 + r[#r+1] = ir 1.23 +end 1.24 + 1.25 +return r