Maemo.org team/Creating an election

These are the steps required to create a new election for the Community Council - essentially the same process applies for a referendum.


 * Get list of maemo.org accounts
 * request a dump of maemo.org accounts including karma and account creation date from Nemein at the karma cut-off date. The format for each row is:

username,"Real name",firstname,surname,emails(separated),"join date",karma,talk profile URL


 * Create election in the database
 * For the Q3 2010 election, that means running the following on the maemoelections database on test.maemo.org:

/* Fields are ID, type ('elections' or 'referendum'), name, start date, end date, # of seats, question */ insert into elections values(10, 'elections', 'Maemo Community Council elections, Q3 2010', '2010-09-16 00:00:00', '2010-09-22 23:59:59', 5, 'In order of preference, which of the following candidates do you want to represent you on the Maemo Community Council?'); /* Fields are id, election id, name - id is auto-increment */ insert into election_choices values (0, 10, 'Andrea Grandi (andy80)'), (0, 10, 'Tim Samoff (timsamoff)'), (0, 10, 'R&uuml;diger Schiller (chemist)'), (0, 10, 'Cosimo Kroll (zehjotkah)'), (0, 10, 'Andrew Flegg (Jaffa)'), (0, 10, 'Stephen Gadsby (sjgadsby)'), (0, 10, 'Felipe Crochik (fcrochik)'), (0, 10, 'Robin Burchell (w00t)'), (0, 10, 'Kathy Smith (revdkathy)'), (0, 10, 'Attila Csipa (achipa)') ;


 * Insert electorate into database
 * Insert the rows into your database using the following (note, we ignore the talk profile URL now, but there is still a column for it in the database):

/* Truncate old electorate table */ truncate electorate; truncate election_tmp_tokens; /* Load data file using LOAD DATA INFILE (or mysqlimport) */ load data infile '/path/to/data/users.csv' into table electorate fields terminated by ',' optionally enclosed by '"'  (username,@dummy,firstname,lastname,@email,creation_date,karma,@talk)   set email=substring_index(@email,';',1),        talk_id=substring_index(@talk,'=',-1) ; /* Delete from electorate anyone with insufficient karma */ delete from electorate where karma < 10; /* Delete accounts created too recently (3 months before end of election) */ delete from electorate where creation_date > '2010-06-23';


 * Generate election tokens and send out emails
 * Tokens and emails are created with scripts in the maemo2midgard repository - create-tmp-tokens.pl and mail-instructions.pl Database credentials are in a private local file called config.pl
 * Before inserting the tmp tokens, we truncate the tokens from the previous elections.
 * We need to modify the email instructions (instructions.txt) every election with the candidate list, links to election materials, etc. First we generate the tmp tokens, insert them in the database by running the resulting file through the mysql client, and then using the instructions and the generated maildata.txt file as inputs, we mail the instructions out.

./create-tmp-tokens.pl    mysql -u -p -h <  ./mail-instructions.pl 

And we're all done!

[Category:Community]