mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 23:06:19 +08:00
FEATURE: Remove restrictions from the chat messages export (#22854)
Now, when we took care of performance infbe0e4c
andad05924
there is no need anymore to restrict the export to - 6 months - 10000 rows
This commit is contained in:
parent
263afe6b6a
commit
cd45f33430
|
@ -2,12 +2,10 @@
|
||||||
|
|
||||||
module Chat
|
module Chat
|
||||||
module MessagesExporter
|
module MessagesExporter
|
||||||
LIMIT = 10_000
|
|
||||||
|
|
||||||
def chat_message_export(&block)
|
def chat_message_export(&block)
|
||||||
# perform 1 db query per month:
|
# perform 1 db query per month:
|
||||||
now = Time.now
|
now = Time.now
|
||||||
from = 6.months.ago
|
from = oldest_message_date
|
||||||
while from <= now
|
while from <= now
|
||||||
export(from, from + 1.month, &block)
|
export(from, from + 1.month, &block)
|
||||||
from = from + 1.month
|
from = from + 1.month
|
||||||
|
@ -38,6 +36,10 @@ module Chat
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def oldest_message_date
|
||||||
|
Chat::Message.order(:created_at).pick(:created_at)
|
||||||
|
end
|
||||||
|
|
||||||
def export(from, to)
|
def export(from, to)
|
||||||
Chat::Message
|
Chat::Message
|
||||||
.unscoped
|
.unscoped
|
||||||
|
@ -45,7 +47,6 @@ module Chat
|
||||||
.includes(:chat_channel)
|
.includes(:chat_channel)
|
||||||
.includes(:user)
|
.includes(:user)
|
||||||
.includes(:last_editor)
|
.includes(:last_editor)
|
||||||
.limit(LIMIT)
|
|
||||||
.find_each do |chat_message|
|
.find_each do |chat_message|
|
||||||
yield(
|
yield(
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user