liquid_feedback_frontend

annotate db/demodata.lua @ 75:733f65c0c0a0

Bugfixes, feature enhancements, code-cleanup, and major work on API

Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
author bsw
date Thu Jul 08 18:44:02 2010 +0200 (2010-07-08)
parents 3bfb2fcf7ab9
children
rev   line source
bsw/jbe@0 1 #!/usr/bin/env lua
bsw/jbe@0 2
bsw/jbe@0 3 member_count = 10000
bsw/jbe@0 4 area_count = 24
bsw/jbe@0 5 issue_count = 1000
bsw/jbe@0 6 policy_count = 3 -- do not change
bsw/jbe@0 7
bsw/jbe@0 8 function write(...)
bsw/jbe@0 9 io.stdout:write(...)
bsw/jbe@0 10 end
bsw/jbe@0 11 function writeln(...)
bsw/jbe@0 12 write(...)
bsw/jbe@0 13 write("\n")
bsw/jbe@0 14 end
bsw/jbe@0 15
bsw/jbe@0 16 math.randomseed(os.time())
bsw/jbe@0 17
bsw/jbe@0 18 writeln('BEGIN;')
bsw/jbe@0 19
bsw/jbe@0 20 for i = 2, member_count do
bsw/jbe@0 21 writeln('INSERT INTO "member" ("login", "name", "ident_number") VALUES (', "'testuser", i, "', 'Benutzer #", i, "', 'TEST", i, "');")
bsw/jbe@0 22 end
bsw/jbe@0 23
bsw/jbe@0 24 for i = 1, member_count do
bsw/jbe@0 25 local is_linked = {}
bsw/jbe@0 26 while math.random(4) > 1 do
bsw/jbe@0 27 local k = math.random(member_count)
bsw/jbe@0 28 if not is_linked[k] then
bsw/jbe@0 29 local public = math.random(2) == 1 and "TRUE" or "FALSE"
bsw/jbe@0 30 writeln('INSERT INTO "contact" ("member_id", "other_member_id", "public") VALUES (', i, ", ", k, ", ", public, ");")
bsw/jbe@0 31 is_linked[k] = true
bsw/jbe@0 32 end
bsw/jbe@0 33 end
bsw/jbe@0 34 end
bsw/jbe@0 35
bsw/jbe@0 36 for i = 2, area_count do
bsw/jbe@0 37 writeln('INSERT INTO "area" ("name") VALUES (', "'Area #", i, "');")
bsw/jbe@0 38 end
bsw/jbe@0 39
bsw/jbe@0 40 local memberships = {}
bsw/jbe@0 41
bsw/jbe@0 42 for i = 1, area_count do
bsw/jbe@0 43 memberships[i] = {}
bsw/jbe@0 44 for j = 1, member_count do
bsw/jbe@0 45 if math.random(4) == 1 then
bsw/jbe@0 46 memberships[i][j] = true
bsw/jbe@0 47 local autoreject = math.random(2) == 1 and "TRUE" or "FALSE"
bsw/jbe@0 48 writeln('INSERT INTO "membership" ("member_id", "area_id", "autoreject") VALUES (', j, ", ", i, ", ", autoreject, ");")
bsw/jbe@0 49 end
bsw/jbe@0 50 end
bsw/jbe@0 51 end
bsw/jbe@0 52
bsw/jbe@0 53 do
bsw/jbe@0 54 local issue_initiative_count = {}
bsw/jbe@0 55 local initiative_draft_count = {}
bsw/jbe@0 56 local initiative_idx = 1
bsw/jbe@0 57 local draft_count = 0
bsw/jbe@0 58 for i = 1, issue_count do
bsw/jbe@0 59 local area = math.random(area_count)
bsw/jbe@0 60 writeln('INSERT INTO "issue" ("area_id", "policy_id") VALUES (', area, ", ", math.random(policy_count), ");")
bsw/jbe@0 61 issue_initiative_count[i] = 1
bsw/jbe@0 62 while math.random(3) > 1 do
bsw/jbe@0 63 issue_initiative_count[i] = issue_initiative_count[i] + 1
bsw/jbe@0 64 end
bsw/jbe@0 65 for j = 1, issue_initiative_count[i] do
bsw/jbe@0 66 writeln('INSERT INTO "initiative" ("issue_id", "name") VALUES (', i, ", 'Initiative #", initiative_idx, "');")
bsw/jbe@0 67 initiative_draft_count[i] = 1
bsw/jbe@0 68 while math.random(4) > 1 do
bsw/jbe@0 69 initiative_draft_count[i] = initiative_draft_count[i] + 1
bsw/jbe@0 70 end
bsw/jbe@0 71 local initiators = {}
bsw/jbe@0 72 local is_used = {}
bsw/jbe@0 73 repeat
bsw/jbe@0 74 local member = math.random(member_count)
bsw/jbe@0 75 if not is_used[member] then
bsw/jbe@0 76 initiators[#initiators+1] = member
bsw/jbe@0 77 is_used[member] = true
bsw/jbe@0 78 end
bsw/jbe@0 79 until math.random(2) == 1
bsw/jbe@0 80 for k = 1, initiative_draft_count[i] do
bsw/jbe@0 81 draft_count = draft_count + 1
bsw/jbe@0 82 writeln('INSERT INTO "draft" ("initiative_id", "author_id", "content") VALUES (', initiative_idx, ", ", initiators[math.random(#initiators)], ", 'Lorem ipsum... (#", draft_count, ")');")
bsw/jbe@0 83 end
bsw/jbe@0 84 for k = 1, #initiators do
bsw/jbe@0 85 local member = math.random(member_count)
bsw/jbe@0 86 writeln('INSERT INTO "initiator" ("member_id", "initiative_id") VALUES (', initiators[k], ", ", initiative_idx, ");")
bsw/jbe@0 87 if math.random(50) > 1 then
bsw/jbe@0 88 writeln('INSERT INTO "supporter" ("member_id", "initiative_id", "draft_id") VALUES (', initiators[k], ", ", initiative_idx, ", ", draft_count - math.random(initiative_draft_count[i]) + 1, ");")
bsw/jbe@0 89 end
bsw/jbe@0 90 end
bsw/jbe@0 91 local probability = math.random(99) + 1
bsw/jbe@0 92 for k = 1, member_count do
bsw/jbe@0 93 if not is_used[k] and (memberships[area][k] and math.random(probability) <= 4 or math.random(probability) == 1) then
bsw/jbe@0 94 writeln('INSERT INTO "supporter" ("member_id", "initiative_id", "draft_id") VALUES (', k, ", ", initiative_idx, ", ", draft_count - math.random(initiative_draft_count[i]) + 1, ");")
bsw/jbe@0 95 end
bsw/jbe@0 96 end
bsw/jbe@0 97 initiative_idx = initiative_idx + 1
bsw/jbe@0 98 end
bsw/jbe@0 99 end
bsw/jbe@0 100 end
bsw/jbe@0 101
bsw/jbe@0 102 writeln('END;')

Impressum / About Us