Vote #78836
完了Show the number of attachments on wiki pages
0%
説明
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.
h2. before
!before.png!
h2. after
!after.png!
Patch: attachment:show_attachments_count_of_wiki_page_trunk_r16963.patch
(Compatible the latest trunk r16963.)
journals
Nice one, although it can slow down wiki page rendering if a page contains lots of attachments.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Alternatively, is there a way of having the files section by expanded by default?
--------------------------------------------------------------------------------
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":http://api.rubyonrails.org/classes/ActiveRecord/Associations/CollectionProxy.html#method-i-count method with "length":http://api.rubyonrails.org/classes/ActiveRecord/Associations/CollectionProxy.html#method-i-length method. With this change, I think the slowdown that Mischa wrote will never happen.
*Vanilla Redmine:*
<pre>
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"]]
</pre>
*With Tomomi Yuzuriha's patch applied:*
It requires one more query ("@SELECT COUNT(*) FROM ...@"). It can cause the slowdown as Mishca pointed out.
<pre>
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"]]
</pre>
*Replaced @count@ with @length@:*
Queries are identical with vanilla Redmine. There isn't "@SELECT COUNT(*) FROM ...@" which can cause the slowdown.
<pre>
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"]]
</pre>
--------------------------------------------------------------------------------
I am setting target version to 4.1.0.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Committed. Thank you for your contribution.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
This change is very small but useful. I think it should be delivered as soon as possible.
--------------------------------------------------------------------------------
Merged to 3.4-stable branch.
--------------------------------------------------------------------------------
related_issues
relates,New,27085,Display a counter beside each tab
relates,Closed,12183,Hide attachments by default on wiki pages
duplicates,Closed,28893,Show number of attached files in Wiki Files-Link