Skip to content

Commit

Permalink
#27 LIMIT 1
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 9, 2018
1 parent 56adf90 commit cd7a3a4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions objects/pipeline.rb
Expand Up @@ -135,8 +135,7 @@ def self.query(campaign = 0)
' AND recipient.active=true',
' AND (recipient.created < NOW() - INTERVAL \'10 MINUTES\' OR recipient.email LIKE \'%@mailanes.com\')',
campaign.zero? ? "AND (#{history}) < c.speed" : "AND c.id = #{campaign}",
'GROUP BY rid',
'LIMIT 1'
'GROUP BY rid'
].join(' ')
end

Expand All @@ -145,7 +144,7 @@ def self.query(campaign = 0)
def fetch_one(postman)
deliveries = Deliveries.new(pgsql: @pgsql)
done = false
@pgsql.exec(Pipeline.query).each do |r|
@pgsql.exec(Pipeline.query + ' LIMIT 1').each do |r|
campaign = Campaign.new(id: r['cid'].to_i, pgsql: @pgsql)
letter = Letter.new(id: r['lid'].to_i, pgsql: @pgsql, tbot: @tbot)
recipient = Recipient.new(id: r['rid'].to_i, pgsql: @pgsql)
Expand Down

0 comments on commit cd7a3a4

Please sign in to comment.