[PATCH] summary, changelog: make the number of comments indicator more accurate

Angel Ezquerra angel.ezquerra at gmail.com
Wed Feb 24 23:42:09 UTC 2016


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1456357243 -3600
#      Thu Feb 25 00:40:43 2016 +0100
# Node ID bad39285457d673a2fa3e6d80ece3a600812c32c
# Parent  05a85a6cecba5c8caeb7996590365d5d9bc523c9
summary, changelog: make the number of comments indicator more accurate

Up until now the number of comments indicator counted both actual comments and
status changes. This was not particularly useful, since the status information
is already shown on the status icon, and opening a changeset page just to see
that it has had its status changed (with no textual comments) is quite annoying.

Instead, show the number of "actual" comments (i.e. those that have some comment
text).

diff --git a/kallithea/templates/changelog/changelog.html b/kallithea/templates/changelog/changelog.html
--- a/kallithea/templates/changelog/changelog.html
+++ b/kallithea/templates/changelog/changelog.html
@@ -120,15 +120,19 @@
                             <div class="log-container">
                                 <div class="message" id="C-${cs.raw_id}">${h.urlify_commit(cs.message, c.repo_name,h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</div>
                                 <div class="extra-container">
-                                    %if c.comments.get(cs.raw_id):
+                                    <% comments_and_status_changes = c.comments.get(cs.raw_id,[]) %>
+                                    %if comments_and_status_changes:
+                                        <% num_actual_comments = len([cm for cm in comments_and_status_changes if cm.text]) %>
+                                        %if num_actual_comments:
                                         <div class="comments-container">
                                             <div class="comments-cnt" title="${_('Changeset has comments')}">
                                                 <a href="${c.comments[cs.raw_id][0].url()}">
-                                                    ${len(c.comments[cs.raw_id])}
+                                                    ${num_actual_comments}
                                                     <i class="icon-comment-discussion"></i>
                                                 </a>
                                             </div>
                                         </div>
+                                        %endif
                                     %endif
                                     %if h.is_hg(c.db_repo_scm_instance):
                                         %for book in cs.bookmarks:
diff --git a/kallithea/templates/changelog/changelog_summary_data.html b/kallithea/templates/changelog/changelog_summary_data.html
--- a/kallithea/templates/changelog/changelog_summary_data.html
+++ b/kallithea/templates/changelog/changelog_summary_data.html
@@ -31,15 +31,19 @@
             </div>
         </td>
         <td class="compact">
-              %if c.comments.get(cs.raw_id,[]):
-               <div class="comments-container">
-                   <div title="${('comments')}">
-                       <a href="${c.comments[cs.raw_id][0].url()}">
-                          <i class="icon-comment"></i>${len(c.comments[cs.raw_id])}
-                       </a>
-                   </div>
-               </div>
+            <% comments_and_status_changes = c.comments.get(cs.raw_id,[]) %>
+            %if comments_and_status_changes:
+              <% num_actual_comments = len([cm for cm in comments_and_status_changes if cm.text]) %>
+              %if num_actual_comments:
+                 <div class="comments-container">
+                     <div title="${('comments')}">
+                         <a href="${c.comments[cs.raw_id][0].url()}">
+                             <i class="icon-comment"></i>${num_actual_comments}
+                         </a>
+                     </div>
+                 </div>
               %endif
+            %endif
         </td>
         <td>
             <a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id)}" class="revision-link">${h.show_id(cs)}</a>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kallithea.patch
Type: text/x-patch
Size: 4141 bytes
Desc: not available
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20160225/52d96878/attachment.bin>


More information about the kallithea-general mailing list