FIX: limit visible revisions history to last 100 (#12946)

This is done to prevent spike memory usage when the number of revisions is very large (thousands) and the post has a significant length.
This commit is contained in:
Joffrey JAFFEUX 2021-05-05 12:18:25 +02:00 committed by GitHub
parent 8f82243ee7
commit b0e9c6e127
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -190,7 +190,12 @@ class PostRevisionSerializer < ApplicationSerializer
def all_revisions
return @all_revisions if @all_revisions
post_revisions = PostRevision.where(post_id: object.post_id).order(:number).to_a
post_revisions = PostRevision
.where(post_id: object.post_id)
.order(number: :desc)
.limit(99)
.to_a
.reverse
latest_modifications = {
"raw" => [post.raw],

View File

@ -3374,7 +3374,7 @@ en:
one: "user"
other: "users"
category_title: "Category"
history: "History"
history: "History, last 100 revisions"
changed_by: "by %{author}"
raw_email: