Patch #27090

Show the number of attachments on wiki pages

Added by Tomomi Yuzuriha about 1 year ago. Updated 5 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Wiki
Target version:3.4.6

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.)

before.png (50.6 KB) Tomomi Yuzuriha, 2017-09-28 04:20

after.png (49.6 KB) Tomomi Yuzuriha, 2017-09-28 04:20

show_attachments_count_of_wiki_page_trunk_r16963.patch Magnifier (615 Bytes) Tomomi Yuzuriha, 2017-09-28 04:38

show_attachments_count_of_wiki_page-v2.diff Magnifier - Replaced "count" method with "length" method. (641 Bytes) Go MAEDA, 2018-01-14 11:07


Related issues

Related to Redmine - Feature #27085: Display a counter beside each tab New
Related to Redmine - Feature #12183: Hide attachments by default on wiki pages Closed
Duplicated by Redmine - Feature #28893: Show number of attached files in Wiki Files-Link Closed

Associated revisions

Revision 17231
Added by Go MAEDA 7 months ago

Show the number of attachments on wiki pages (#27090).

Patch by Tomomi Yuzuriha.

Revision 17364
Added by Go MAEDA 5 months ago

Merged r17231 from trunk to 3.4-stable (#27090).

History

#1 Updated by Mischa The Evil about 1 year ago

  • Target version set to Unplanned

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

#2 Updated by Toshi MARUYAMA 12 months ago

#3 Updated by arturo flores 12 months ago

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

#4 Updated by Go MAEDA 9 months 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"]]

#5 Updated by Go MAEDA 9 months ago

  • Target version changed from Unplanned to 4.1.0

I am setting target version to 4.1.0.

#6 Updated by Go MAEDA 7 months ago

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

#7 Updated by Go MAEDA 7 months 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.

#8 Updated by Go MAEDA 7 months ago

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

#9 Updated by Go MAEDA 5 months ago

  • Duplicated by Feature #28893: Show number of attached files in Wiki Files-Link added

#10 Updated by Go MAEDA 5 months 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.

#11 Updated by Go MAEDA 5 months ago

  • Status changed from Reopened to Closed

Merged to 3.4-stable branch.

Also available in: Atom PDF