# -*- encoding : utf-8 -*-
used_codes = [
'oBtn69Uvz',
'UeI6fKioI',
'Ia2hz5PnH',
'r2rWfVK4Q',
'RMt+FTgx0',
'ps4vUze6+',
'P29fWN9uy',
'sss',
'vwXfch1HJ',
'aaa',
'LMFA6IdYh',
'7pNe1xelg',
'5MPUy/1Kn',
'ssOhLjZSG',
'wvaqB9pla',
'bVvTTi5rZ',
'Pv2G/OUH/',
'0iGN9bOlt',
'k6ykZJOxo',
'iKGI+vo6U',
'PWdbMSx2l',
'mOXxezKd5',
'W9IZyqCBN',
'MTfODh/yV',
'gpPDbnewz',
'Q6aoXvuUv',
'C4JZF+kaX',
'j+SiAX6lU',
'xcPDY48/P',
'iXer9LfaX',
'4Soqb1r9J',
'kpesNCviF',
'kfai0akd6',
'DwZ6WGB4O',
'QK6poEvhU',
'508Zr4i7a',
'XlzVh2YiV',
'Wtz50RaI8',
'+HbYxvJ85',
'LduEPJ8/k',
'rXnTZr/mZ',
'kidUJBpzy',
'+3VyipXse',
'RvPJj10BY',
'spa1IYZDp',
'obMOyKc88',
'zz8QS5rNk',
'9LXO5PGsQ',
'8e5uGKBo8',
'jFlYCLe57',
'5WmGfoLAz',
'VSdRO90jk',
'4owVb/gAr',
'nH7yeqd61',
'2DKWD/Yx',
'0447dc987464570c5511206e17bf6897',
'MZeq5D5M7',
'wPaGs90S+',
'09Y0CdUCH',
'ELVOLVASKY69',
'sBvU4CvRq',
'kuuf+yfd0',
'BMOFrKvES',
'pANL64Azv',
'fJUNhGZfV',
'4HHFvfNwN',
'uAsEbnXVb',
'DrLEc1xyG',
'5XqJZxDQr',
'7OwQqae8n',
'ZhVJmS6wY',
'xg+Sc5Yfm',
'0GRTnrc7Q',
'DbJAWDNjD',
'7oAEqel1j',
'fubXXWOH6',
'1o93ywdgU',
'bAyUXUQFL',
'DpU3LvBWd',
'LOGww59mp',
'LYH6lWRgW',
'XkL14A1gW',
'2CapMqUG9',
'UjYxHnAhD',
'4xvqvp7wm',
'VRa8S4zSE',
'Y33KLTqZz',
'4dGegwika',
'15joNojzt',
'wCElg3w2U',
'1693',
'Vf/Mv2HB3',
'REbb9s3v3',
'gM/5jqPZo',
'qJv2jHrG8',
'hVxYtC6m4',
'24IvLqhOy',
'JOGh9Lv5T',
'bLU4tQ29U',
'4mKqHK7Ro',
'+KZMhk7nB',
'wGSys5sS3',
'ua20x4m3o',
'bzyhE9YWU',
'cCDRS31YZ',
'QlW0OsBz7',
'gLOOuyKxf',
'yfUBa0ZDP',
'9lD+rdn1s',
'7xA1k+HEt',
'8r+2naowH',
'JWM92JcfP',
'KY7T5H4Wh',
'JkH7qBEb6',
'f+4jrgWC1',
'YGohkfM5M',
'pHdd/wv3d',
'0ohjMf7X8',
'eDyh/+RfX',
'rO9sVAVFf',
'9WJcyJT80',
'2c6JPFuAr',
'uROavuqb0',
'LksumoCD9',
'sF1vs958W',
'Gamersmafiageist 2011',
'JNHvLvxY+',
'XJqF+HLBN',
'jptuG7ygN',
'ZH2idmDrn',
'U8pUpiaWX',
'H/4eAtGEw',
'/9Njvt1gE',
'MK+b635Xg',
'LzXpo+oH9',
'BJrpsJcp3',
'A5HO/vc5C',
'kZMSjeTfd',
'F8KflYuXN',
'daLogD/9K',
'KCpdTBhlO',
'NCyC/U3lO',
'96nJJmQZp',
'gFMjxDYFd',
'02E54m3g9',
'9ZH22DEqP',
'PbzqztTWf',
'6MRLtW/5f',
'kYUQnfSd/',
'vocs4ZIn5',
'ZrJ//fEkM',
'gIyl2VrUb',
'+kI05F6Xl',
'/kubjxEob',
'dZlVoed1G',
'Pm5eyvIxw',
'7rG3SAFRi',
'rVPfmaHiA',
'i5XL7+fEx',
'6eOXVS8b6',
'838s86Seq',
'94815',
'pQlfNjtof',
'pQlfNjtof',
'/ZP2/rzmK',
'f88K8zU3U',
'pKuaZC+Un',
'6IrUy96j5',
'Dqxphxfav',
'uGzzPQnPb',
'+rBLe8kmD',
'ftm7CqlmL',
'FMnWVOKUm',
'IGYAq0tX0',
'vAypL8Glc',
'S5i0DLeub']

namespace :gm do
  desc "GmGeist Warning 2011"
  task :gmgeist2011 => :environment do
    nagato = Ias.nagato
    subject = '¡Sólo quedan 3 días para que concluya la GmGeist 2011!'
    body = '''Si todavía no has rellenado la primera encuesta anual de Gamersmafia esta es tu oportunidad:

    http://gamersmafia.com/noticias/show/45704

    Tu opinión es imprescindible para poder decidir el rumbo de la comunidad.
    ¡Muchas gracias!
    '''
    count = 0
    joined_codes = used_codes.join('\',\'')
    cond_subselect = "id not IN (SELECT user_id FROM gamersmafiageist_codes WHERE code IN ('#{joined_codes}'))"
    User.settled.can_login.find(:all, :conditions => "notifications_global = 't' AND #{cond_subselect}", :order => 'id').each do |recipient|
      m = Message.new(:title => subject, :sender => nagato, :recipient => recipient, :message => body)
      m.save
      Kernel.sleep 1
      count += 1
      puts "sending to:    #{recipient.login} (user_id: #{recipient.id})"
      puts "current count: #{count}" if count % 100 == 0
    end
  end
end
