liquid_feedback_frontend
annotate db/demodata.lua @ 9:0ee1e0c42d4c
Version beta5
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
author | bsw |
---|---|
date | Mon Jan 04 12:00:00 2010 +0100 (2010-01-04) |
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;') |