#1709 closed defect (fixed)
[patch] [magic-removal] updated comments module's view/model to use the new m-r apis
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | magic-removal |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
guys,
today while I'm using the comments module to implement something, I
guess I found two bugs:
- in the models.py, the get_list_with_karma method should be updated to use the extra() method to inject the "select" kwargs, otherwise, the templatetag get_comment_list won't work;
- in the views/comments.py, self.user_cache.get_comments_comment_count() - the get_comments_comment_count() api doesn't exist now, should be updated to use the self.user_cache.comment_set.count() to get the comments count.
I've done some debug work to check the patch for models.py, pls check
the the following sqls to confirm if my patch work as expected:
before patching:
{'sql': 'SELECT "comments_comment"."id","comments_comment"."user_id","comments_comment"."content_type_id", "comments_comment"."object_id","comments_comment"."headline","comments_comment"."comment", "comments_comment"."rating1","comments_comment"."rating2","comments_comment"."rating3", "comments_comment"."rating4","comments_comment"."rating5","comments_comment"."rating6", "comments_comment"."rating7","comments_comment"."rating8","comments_comment"."valid_rating", "comments_comment"."submit_date","comments_comment"."is_public","comments_comment"."ip_address", "comments_comment"."is_removed","comments_comment"."site_id" FROM "comments_comment" INNER JOIN "django_content_type" AS "comments_comment__content_type" ON "comments_comment"."content_type_id" = "comments_comment__content_type"."id" WHERE ("comments_comment__content_type"."model" = article AND "comments_comment"."site_id" = 1 AND "comments_comment__content_type"."app_label" = aiyo AND "comments_comment"."object_id" = 32) ORDER BY "comments_comment"."submit_date" DESC', 'time': '0.001'},
patched:
{'sql': 'SELECT "comments_comment"."id","comments_comment"."user_id","comments_comment"."content_type_id", "comments_comment"."object_id","comments_comment"."headline","comments_comment"."comment", "comments_comment"."rating1","comments_comment"."rating2","comments_comment"."rating3", "comments_comment"."rating4","comments_comment"."rating5","comments_comment"."rating6", "comments_comment"."rating7","comments_comment"."rating8","comments_comment"."valid_rating", "comments_comment"."submit_date","comments_comment"."is_public","comments_comment"."ip_address", "comments_comment"."is_removed","comments_comment"."site_id",(SELECT COUNT(*) FROM comments_karmascore, comments_comment WHERE comments_karmascore.comment_id=comments_comment.id AND score=1) AS "_karma_total_good",(SELECT COUNT(*) FROM comments_karmascore, comments_comment WHERE comments_karmascore.comment_id=comments_comment.id AND score=-1) AS "_karma_total_bad" FROM "comments_comment" INNER JOIN "django_content_type" AS "comments_comment__content_type" ON "comments_comment"."content_type_id" = "comments_comment__content_type"."id" WHERE ("comments_comment__content_type"."model" = article AND "comments_comment"."site_id" = 1 AND "comments_comment__content_type"."app_label" = aiyo AND "comments_comment"."object_id" = 32) ORDER BY "comments_comment"."submit_date" DESC', 'time': '0.001'},
Attachments (1)
Change History (3)
by , 19 years ago
Attachment: | comments.diff added |
---|
comment:1 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
patch for updating the comments module's view/model