Guest User

Untitled

a guest
May 20th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.32 KB | None | 0 0
  1. def teste3 = {
  2.         def userStats = []
  3.         def textoS
  4.         def email = Users.get(5559).email
  5.         def dtInicio, dtFim
  6.        
  7.         use(TimeCategory){
  8.         dtInicio = new Date() - 1.months
  9.         dtFim = new Date() + 1.days
  10.         }
  11.        
  12.         def sql = Sql.newInstance( 'jdbc:postgresql://localhost:5432/ad', 'postgres',
  13.                        'postgres', 'org.postgresql.Driver' )
  14.         sql.eachRow('select count(prog_title) contagem, prog_title,users.email from programmation join alert on programmation.id = alert.program_id join users on alert.user_id = users.id where users.email=\''+email+'\' and alert.hora_dispara between \''+dtInicio+'\' and \''+dtFim+'\' group by alert.user_id, prog_title,email order by contagem desc limit 10 ') {
  15.            userStats.add(new UserStats(program_title:it.prog_title,user_email:it.email,frequencia:it.contagem))
  16.         }
  17.         if(userStats == null){
  18.            
  19.         }else{
  20.             textoS = 'TvMEGAzineP Top ' + userStats.size() + ' Programms:\n\n'
  21.            
  22.             userStats.each{ us ->
  23.                 textoS = textoS + '\t\t\t\t - ' + us.program_title + '\n'
  24.             }
  25.         }
  26.        FbUtil fb = new FbUtil()        
  27.                
  28.                     fb.sendComent(Users.get(5559).fbtoken, textoS)
  29.                
  30.     }
Add Comment
Please, Sign In to add comment