# To delete spam e = Elt.find_by_sql("SELECT * FROM elts ORDER BY created_on DESC LIMIT 1").first; puts e.id; e.person.id; puts e.children.size; puts e.person.elts.size if e.person puts e.destroy; e.person.destroy e.person.elts.each { |c| puts c.destroy }.size if e.person; e.person.destroy create/delete el add/see/remove user(s) mail, name What is below is just for future personal reference... http://www.ajaxchat.org/chat/ # Console code to reset threads from their original mails: >> elts=Mail.find_all.select{|m|m.file and mail=TMail::Mail.parse(m.file) and reply=mail.in_reply_to and mailObject=Mail.find_by_message(reply) and mailObject.elt.id!=m.elt.parent_id}.collect{|m| {:elt=>m.elt.id, :parent=>Mail.find_by_message(TMail::Mail.parse(m.file).in_reply_to).elt.id}}; puts elts.size >> elts.each{|e|print e[:elt], ' ', e[:parent], ' '; puts Elt.update_all("parent_id='#{e[:parent]}'", "id='#{e[:elt]}'")}; puts elts.size # To get and remove duplicate messages >> messages=Mail.find_by_sql "select message from mails group by message having count(message) > 1"; puts messages.length >> messages.each{ |m| mail=Mail.find_all_by_message m.message; mail.each{|m| print m.elt.id, ' ', m.elt.subject, ' ', m.elt.children.size; puts } }; puts messages.length >> messages.each{ |m| mail=Mail.find_all_by_message m.message; mail.each_index{|i| m=mail[i]; print i, ' ', m.elt.id, ' ', m.elt.subject, ' ', m.elt.children.size; m.elt.destroy if i>0 and m.elt.children.size==0; puts } }; puts messages.length # To get all existing votes elts=Elt.find(:all, :conditions => ["body LIKE '%%+1%%' OR body LIKE '%%0%%' OR body LIKE '%%-1%%'"]); puts elts.size elts.each { |e| print '(', Regexp.last_match(1), ')' if e.body =~ /^\s*(-1|0|\+1)(\s*|$)/ }; puts; puts elts.size elts.each { |e| e.vote(Regexp.last_match(1), e.person) if e.body =~ /^\s*(-1|0|\+1)(\s*|$)/ }; puts; puts elts.size UPDATE elts SET elts_count = (SELECT COUNT(*) FROM elts e2 WHERE e2.parent_id = elts.id); UPDATE elts SET lft = NULL, rgt = NULL; # To reconstruct the nested tree set def construction(e, counter) e.lft = counter counter += 1 e.children.each { |c| counter = construction(c, counter) } e.rgt = counter counter += 1 e.save counter end e=Elt.find('ROOT') construction(e, 0) ALTER TABLE elts ADD CONSTRAINT elts_unique_lft UNIQUE (lft); ALTER TABLE elts ADD CONSTRAINT elts_unique_rgt UNIQUE (rgt); SELECT * FROM person_mails; INSERT INTO person_mails (person_id, mail_id, created_on) VALUES ('first', 'aGaGwUHxCr25c5aaVnmTrI', now()); select id from mails; select count(*) from mails; select * from people; select * from users; select * from subscriptions; select * from person_mails; select distinct last_activity from elts; UPDATE elts SET last_activity = (SELECT MAX(created_on) FROM elts c WHERE elts.lft <= c.lft AND c.rgt <= elts.rgt); Processing EltController#create (for 192.168.0.254 at 2007-02-11 00:07:05) [POST] Session ID: 23a1ab5f9b11763838d64c50157610f3 Parameters: {"commit"=>"Propose!", "elt"=>{"body"=>"arg", "subject"=>"Re: Testez", "parent_id"=>"Testez"}, "submit"=>"preview", "action"=>"create", "id"=>"Testez", "controller"=>"elt"} Response body was encoded with gzip Completed in 0.05879 (17 reqs/sec) | Rendering: 0.05682 (96%) | DB: 0.00072 (1%) | 200 OK [http://leparlement.org/elt/create/Testez?submit=preview] # To get anonymous votes Elt.find_all_by_person_id(nil).select { |e| e.body == "+1" or e.body == "0" or e.body == "-1" }.select { |e| e.children_count == 0 }.each { |e| e.reload; puts e.id }.size Choice.find_all_by_person_id(nil).each { |c| c.reload; puts c.destroy }.size Elt.find_all_by_person_id(nil).select { |e| e.body == "+1" or e.body == "0" or e.body == "-1" }.select { |e| e.children_count == 0 }.each { |e| e.reload; e.parent.choices.select { |c| not c.person }.each { |c| print c.elt_id }; puts e.id }.size # UTF 8 goodness! def u(tStrin) tStrin.gsub(/\xC3 /, "à").gsub(/\xC3 /, "à").gsub(/\x9E/, "Ẑ").gsub(/\xA0/, " ").gsub(/\xA4/, "€").gsub(/\xA7/, "§").gsub(/\xAB/, "«").gsub(/\xAD/, " ").gsub(/\xB0/, "°").gsub(/\xB4/, "'").gsub(/\xB7/, "·").gsub(/\xBB/, "»").gsub(/\xC4/, "Ä").gsub(/\xC5/, "Å").gsub(/\xC8/, "È").gsub(/\xC9/, "É").gsub(/\xD0/, "Ð").gsub(/\xD6/, "Ö").gsub(/\xE0/, "à").gsub(/\xE2/, "â").gsub(/\xE4/, "ä").gsub(/\xE5/, "å").gsub(/\xE7/, "ç").gsub(/\xE8/, "è").gsub(/\xE9/, "é").gsub(/\xEA/, "ê").gsub(/\xEA/, "ê").gsub(/\xEB/, "ë").gsub(/\xEE/, "î").gsub(/\xEF/, "ï").gsub(/\xF4/, "ô").gsub(/\xF6/, "ö").gsub(/\xF8/, "ø").gsub(/\xF9/, "ù").gsub(/\xFB/, "û").gsub(/\x85/, "…").gsub(/\x91/, "‘").gsub(/\x92/, "’").gsub(/\x93/, "“").gsub(/\x94/, "”").gsub(/\x96/, "–") end mails2.each { |m| m.file.each { |l| puts "\n#{l} --- #{u(l)} #{l.to_yaml}" unless (l.isutf8 or u(l).isutf8) } }.size elts = Elt.find(:all).select { |e| !e.body.isutf8 if e.body }; puts elts.size elts2 = elts.reject { |e| u(e.body).isutf8 }; puts elts2.size elts2.each { |e| e.body.each { |l| puts "#{l} #{l.to_yaml}" unless l.isutf8 or u(l).isutf8 } }.size elts2.each { |e| e.body = u(e.body); e.save }.size mails = Mail.find(:all).select { |m| !m.file.isutf8 if m.file }; puts mails.size mails2 = mails.reject { |m| u(m.file).isutf8 }; puts mails2.size mails2.reject { |m| u(m.file).each { |l| puts l.to_yaml unless l.isutf8 } }.size mails2.reject { |m| m.file.each { |l| puts "#{l} #{u(l)}" unless (l.isutf8 or u(l).isutf8) } }.size mails.each { |m| m.file = u(m.file); m.save }.size --------------- Electoral lists How to be sure that our voice counts? That it counts equally to all others. In politics, a mere one can subvert the whole, and use his power to tilt the balance all the way toward him. To that end ______________________________________________________________________________________________________________________________ ------------------------------------------------------------------------------------------------------------------------------ Listes électorale Comment être sûr que notre voix compte? Qu'elle compte à égalité de toutes les autres. Les arrangements sont multiples, on ne fait voter que les riches, on écarte les femmes ou les étrangers, on s'arrange pour que la population votant pour son opposant soit disqualifiée, on fait voter les morts, un grand classique! - intro - les problèmes potentiels * manipulation - les délais - l'identité - conclusion ======= What it is Why it is so important Who should be concerned with it