avatar

569

Fix the database usage for finding snipes, so it doesn't find completed snipes as current.

by mrs, 24 Jul, 2008 12:05 AM
556 569  
17641764     return getRealDatabase().count_by("ended = 1");
17651765   }
17661766 
1767   private static final String snipeFinder = "(snipe_id IS NOT NULL OR multisnipe_id IS NOT NULL) AND ended != 1";
1768 
17671769   public static int snipedCount() {
1768     return getRealDatabase().count_by("(snipe_id IS NOT NULL OR multisnipe_id IS NOT NULL)");
1770     return getRealDatabase().count_by(snipeFinder);
17691771   }
17701772 
17711773   public static AuctionEntry nextSniped() {
1772     String sql = "SELECT entries.* FROM entries, auctions WHERE " +
1773         "(entries.snipe_id IS NOT NULL OR entries.multisnipe_id IS NOT NULL) AND " +
1774         "ended != 1 AND " +
1775         "(entries.auction_id = auctions.id) " +
1776         "ORDER BY auctions.ending_at ASC";
1774     String sql = "SELECT entries.* FROM entries, auctions WHERE " + snipeFinder + 
1775         " AND (entries.auction_id = auctions.id) ORDER BY auctions.ending_at ASC";
17771776     return (AuctionEntry) findFirstBySQL(AuctionEntry.class, sql);
17781777   }
17791778