Closed (fixed)
Project:
Drigg
Version:
5.x-1.33
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
18 Jul 2008 at 08:33 UTC
Updated:
15 Aug 2008 at 11:15 UTC
We post scoops to groups and for some reason (which I have not investigated), scoops were listed twice in the "best scoops" block.
I modified the query in the file drigg/drigg_blocks/drigg_blocks.module:
$query="SELECT * FROM {node} n LEFT JOIN {votingapi_cache} vc ON n.nid = vc.content_id WHERE ".drigg_votingapi_query('vc')." AND vc.value <> 0 AND n.created > UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60*".variable_get("drigg_block_${var_name}_days", 48)." $only_promoted AND n.status=1 GROUP BY n.nid ORDER BY vc.value DESC LIMIT %d";
to:
$query="SELECT * FROM {node} n LEFT JOIN {votingapi_cache} vc ON n.nid = vc.content_id WHERE ".drigg_votingapi_query('vc')." AND vc.value <> 0 AND n.created > UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60*".variable_get("drigg_block_${var_name}_days", 48)." $only_promoted AND n.status=1 GROUP BY n.nid ORDER BY vc.value DESC LIMIT %d";
The addition is the GROUP BY clause.
Is this the correct way of solving my problem? If not, do you have a suggestion were to start looking on WHY the posts appear twice?
Bart.
Comments
Comment #1
mercmobily commentedHi,
Can you please provide the line number? Also, you posted the same query twice...
I think it's really strange that a scoop is posted twice. I don't think we should need the group by, but will investigate this further. In the meantime, can you have a look at the db to see why you are getting this?
I think i might have missed the content_type filter to the query, actually, so the query is picking up comments as well. Could that be it? (you tell me, since you have the db there...!)
Merc.
Comment #2
mercmobily commentedHi,
Hellow?
Merc.
Comment #3
analogious commentedYes, I accidentally posted the modified sql twice.
it's line: 324 of the file drigg/drigg_blocks/drigg_blocks.module I modified.
Like you suspected, blog posts and comments also appear in the block.
Posts do not appear twice any more when I revert the query to the original one. I played arround with the block config, but I cannot reproduce it for now. I'll let you know when it happens again including information regarding the db.
Bart.
Comment #4
mercmobily commentedHi,
Can you please _quickly_ confirm that if you add:
AND n.type='drigg'
To the query, the problem is fixed?
Can you please also confirm that the queries on lines 214 and 256 ALSO need fixing? (with the AND n.type='drigg')
I have a pending commit right now. A swift response would simplify Drigg's development immensely. Thanks.
Merc.
Comment #5
mercmobily commentedHi,
"A swift response would simplify Drigg's development immensely. Thanks."
Merc.
Comment #6
analogious commentedHi,
It does fix my problem. Only scoops are displayed now in the best scoops block.
214 and 256 are ok already.
Thanks.
Bart.
Comment #7
mercmobily commentedok thanks
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.