Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1709 closed defect (fixed)

[patch] [magic-removal] updated comments module's view/model to use the new m-r apis

Reported by: EricHsu<nkeric@…> 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)

comments.diff (2.0 KB ) - added by EricHsu 19 years ago.
patch for updating the comments module's view/model

Download all attachments as: .zip

Change History (3)

by EricHsu, 19 years ago

Attachment: comments.diff added

patch for updating the comments module's view/model

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [2775]) magic-removal: Fixed #1709 -- Updated comments app to use magic-removal APIs. Thanks, Eric Hsu

comment:2 by Adrian Holovaty, 18 years ago

milestone: Version 0.92

Milestone Version 0.92 deleted

Note: See TracTickets for help on using tickets.
Back to Top