High Bid Views Filter
| Project: | Ubercart Auction |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
The views filter for highest bid isn't working correctly.
Here's copy of the query that's getting generated.
SELECT node.nid AS nid,
node.type AS node_type,
node_data_field_image_cache.field_image_cache_fid AS node_data_field_image_cache_field_image_cache_fid,
node_data_field_image_cache.field_image_cache_list AS node_data_field_image_cache_field_image_cache_list,
node_data_field_image_cache.field_image_cache_data AS node_data_field_image_cache_field_image_cache_data,
node_data_field_image_cache.delta AS node_data_field_image_cache_delta,
node.vid AS node_vid,
node.title AS node_title,
uc_products.weight AS uc_products_weight,
uc_auction.expiry AS uc_auction_expiry,
uc_auction.start_price AS uc_auction_start_price,
uc_auction_bids.amount AS uc_auction_bids_amount
FROM node node
LEFT JOIN uc_auction uc_auction ON node.nid = uc_auction.nid
LEFT JOIN uc_products uc_products ON node.vid = uc_products.vid
LEFT JOIN content_field_image_cache node_data_field_image_cache ON node.vid = node_data_field_image_cache.vid
LEFT JOIN uc_auction_bids uc_auction_bids ON uc_auction.high_bid = uc_auction_bids.bid
WHERE (node.status <> 0) AND (node.type IN ('product')) AND (uc_auction.expiry >= ***CURRENT_TIME***+0) AND (uc_auction.high_bid >= 0) AND (uc_auction.high_bid <= 99) AND (uc_products.weight >= 0) AND (uc_products.weight <= 10000)
ORDER BY uc_auction_expiry DESC
It looks like the problem is the condition at the bottom where uc_auction.highbid is getting checked. highbid in this case is just the bid id. What should be getting checked is uc_auction_bids.amount.
I'm still a little unfamiliar with views coding.
Can someone help?
Thanks

#1
I have no idea where the "AND (uc_auction.high_bid >= 0) AND (uc_auction.high_bid <= 99)" part is coming from; that's weird. Do you think you could attach a screenshot of your Views page while you're editing the view?
#2
Here's the screen cap. I'm using the default uc_products view and added a couple filters from the auction module.
Hope this helps. Let me know if you need anything else.
#3
Oh, okay. I get it. It's filtering by the wrong value.
Sorry about that. Once I can work on this module again, I'll look into it, but frankly all this Views stuff can be pretty friggin' hard at times. So unless I can wrangle in someone smarter than me to help me on that, I can't guarantee I'll be able to fix it. If nothing else, I might end up "fixing" it so that Views won't let you try to filter on that field anymore.
Sorry I can't give you a better answer than that, but it's the truth.
#4
I'll spend some more time on this too. I was hoping it was a simple bug to fix and I was just missing something.
I'll post a patch if I come up with anything.
#5
Ok, I think I've figured this one out. Since there wasn't an explicit high bid filter handler, we were using the generic numeric one that comes with views. So, I created a uc_auction_handler_filter_high_bid.inc file, made sure the right tables were being joined, copied over the query function from the generic numeric handler and changed the field it was acting on to the correct uc_auction_bids.amount field.
I've included the new inc file and a patch for uc_auction.views.inc.
Seems to work fine for my needs. Let me know if you can poke any holes in it.
#6
What am I looking at in uc_auction_handler_filter_is_auc.inc in that archive? Why did you put code from there? And why did you remove the render function? I don't understand what you're trying to give me here.
#7
There shouldn't be anything from uc_auction_handler_filter_is_auc.inc. I created a new filter handler called uc_auction_handler_filter_high_bid.inc. As far as I know, filter handlers shouldn't have a render function.
Just rechecked the archive I uploaded and there should be two files in there:
uc_auction_handler_filter_high_bid.inc
uc_auction.views.inc.patch
Hope this helps.
#8
Oh, I get it. The …filter_high_bid.inc file contains comments from …filter_is_auc.inc, which was confusing me - I guess you duped that file to create it.
It'll need some tweaking - you're not creating $join as a new views_join() before you're using it… does that even work? And also, this should return the starting price if there are currently no bids on the product - but it's a start. Thanks.
#9
Sorry about the comments. Always last thing I look at.
Looks like not having the new views_join() works, but I've put it back in there just to be on the safe side. I've been racking my brain on how to get it to return products that don't have any bids though. Any ideas?
I've also noticed that the high_bid field handler seems to suffer from a similar problem. The starting price is returned if there are no bids, but the sort ends up being wrong giving a product with no bids a zero valued high_bid. Not sure if this is by design or not.
Any help would be greatly appreciated. I'll try do some more work on this too.
#10
The views filter for highest bidder / winner of the auction isn't working correctly, too. I built a view containing a field that should show the current highest bidder or winner of the auction if auction is expired, so that the creator of auctions has an overview of his items. But the view does not show the high bidder but the creators username. Is there an easy way to fix that in the uc_auction_handler_field_high_bidder.inc?
#11
The high bidder field works fine in my testing. Are you using the latest developer release? We should probably make this a separate issue since the two don't seem to be related.
#12
I'm beginning to think the easiest way to get this all to work would be to actually add the starting price as an initial bid. This way when we join the uc_auction and uc_auction_bid tables, it'll return at least one result. We'd have to add a field to the uc_auction_bids table to signify the bid was a starting bid, but then we could also get rid of the starting price in the uc_auction table.
I realize this is a big change, but it seems like it might simplify some queries.
What do you think? I'd be happy to do the work on this if it would get included.
Thanks
#13
Zisinos, by "filter," did you mean "field?" I can't get the field to work incorrectly either, and there isn't a filter for the current high bidder.
scottg: That's creative, but still a hack I'd rather avoid.
I wonder if there's a module out there that can combine the results of two Views… then you can make a view which filters by bids = 0 and starting price > X, then another one by high bid > X, and combine the results, hopefully eliminating duplicates… Ugh, still a hack, but it might do the job for someone who really needs it.
I'll ask around a bit. For now, I've tested your patches and they seem good, so I'm going to go ahead and commit them. Since the filter says it filters by high bid, not including products with no bids isn't technically wrong… but it is inconsistent with the rest of UC Auction.
#14
I think I've finally got this figured out. The amounts with no bids were coming back NULL, but were being excluded by the greater/less than conditions. I added an OR condition for NULL amounts and rewrote the numeric filters between operator to work with the new condition.
Let me know what you think. Now I just need to figure out the sort by high bid.