Project

General

Profile

Actions

Patch #27090

closed

Show the number of attachments on wiki pages

Added by Tomomi Yuzuriha about 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Wiki
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

I noticed the problem that users cannot know whether there are any attachments unless users expand the "File" section by clicking it.

To resolve the problem, I suggest showing attachments count on "Files” section.
Please see the screenshots below for the details.

before

after

Patch: show_attachments_count_of_wiki_page_trunk_r16963.patch
(Compatible the latest trunk r16963.)


Files

before.png (50.6 KB) before.png Tomomi Yuzuriha, 2017-09-28 04:20
after.png (49.6 KB) after.png Tomomi Yuzuriha, 2017-09-28 04:20
show_attachments_count_of_wiki_page_trunk_r16963.patch (615 Bytes) show_attachments_count_of_wiki_page_trunk_r16963.patch Tomomi Yuzuriha, 2017-09-28 04:38
show_attachments_count_of_wiki_page-v2.diff (641 Bytes) show_attachments_count_of_wiki_page-v2.diff Replaced "count" method with "length" method. Go MAEDA, 2018-01-14 11:07

Related issues

Related to Redmine - Feature #27085: Display a counter beside each tabNew

Actions
Related to Redmine - Feature #12183: Hide attachments by default on wiki pagesClosedJean-Philippe Lang

Actions
Has duplicate Redmine - Feature #28893: Show number of attached files in Wiki Files-LinkClosed

Actions
Actions #1

Updated by Mischa The Evil about 7 years ago

  • Target version set to Unplanned backlogs

Nice one, although it can slow down wiki page rendering if a page contains lots of attachments.

Actions #2

Updated by Toshi MARUYAMA about 7 years ago

Actions #3

Updated by arturo flores about 7 years ago

Alternatively, is there a way of having the files section by expanded by default?

Actions #4

Updated by Go MAEDA almost 7 years ago

Mischa The Evil wrote:

Nice one, although it can slow down wiki page rendering if a page contains lots of attachments.

I slightly improved the Tomomi Yuzuriha's patch to avoid the slowdown caused by additional SQL query ("SELECT COUNT(*) FROM ..."). I replaced count method with length method. With this change, I think the slowdown that Mischa wrote will never happen.

Vanilla Redmine:

  Attachment Load (0.4ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 1], ["container_type", "WikiPage"]]
  Rendered wiki/_content.html.erb (147.0ms)
  CACHE Attachment Load (0.0ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 1], ["container_type", "WikiPage"]]

With Tomomi Yuzuriha's patch applied:

It requires one more query ("SELECT COUNT(*) FROM ..."). It can cause the slowdown as Mishca pointed out.

  Attachment Load (0.2ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 1], ["container_type", "WikiPage"]]
  Rendered wiki/_content.html.erb (74.0ms)
   (0.2ms)  SELECT COUNT(*) FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ?  [["container_id", 1], ["container_type", "WikiPage"]]
  CACHE Attachment Load (0.0ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 1], ["container_type", "WikiPage"]]

Replaced count with length:

Queries are identical with vanilla Redmine. There isn't "SELECT COUNT(*) FROM ..." which can cause the slowdown.

  Attachment Load (0.2ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 1], ["container_type", "WikiPage"]]
  Rendered wiki/_content.html.erb (151.1ms)
  CACHE Attachment Load (0.0ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 1], ["container_type", "WikiPage"]]

Actions #5

Updated by Go MAEDA almost 7 years ago

  • Target version changed from Unplanned backlogs to 4.1.0

I am setting target version to 4.1.0.

Actions #6

Updated by Go MAEDA almost 7 years ago

  • Related to Feature #12183: Hide attachments by default on wiki pages added
Actions #7

Updated by Go MAEDA almost 7 years ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version changed from 4.1.0 to 4.0.0

Committed. Thank you for your contribution.

Actions #8

Updated by Go MAEDA almost 7 years ago

  • Subject changed from Show attachments count in "Files” section of the Wiki page to Show the number of attachments on wiki pages
Actions #9

Updated by Go MAEDA over 6 years ago

  • Has duplicate Feature #28893: Show number of attached files in Wiki Files-Link added
Actions #10

Updated by Go MAEDA over 6 years ago

  • Status changed from Closed to Reopened
  • Target version changed from 4.0.0 to 3.4.6

This change is very small but useful. I think it should be delivered as soon as possible.

Actions #11

Updated by Go MAEDA over 6 years ago

  • Status changed from Reopened to Closed

Merged to 3.4-stable branch.

Actions

Also available in: Atom PDF