DEV: make sure we don't load all data into memory when exporting chat messages (#22276)

This commit makes sure we don't load all data into memory when doing CSV exports. 
The most important change here made to the recently introduced export of chat 
messages (3ea31f4). We were loading all data into memory in the first version, with 
this commit it's not the case anymore.

Speaking of old exports. Some of them already use find_each, and it worked as 
expected, without loading all data into memory. And it will proceed working as 
expected after this commit.

In general, I made sure this change didn't break other CSV exports, first manually, and 
then by writing system specs for them. Sadly, I haven't managed yet to make those 
specs stable, they work fine locally, but flaky in GitHub actions, so I've disabled them 
for now.

I'll be making more changes to the CSV exports code soon, those system specs will be 
very helpful. I'll be running them locally, and I hope I'll manage to make them stable 
while doing that work.
This commit is contained in:
Andrei Prigorshnev
2023-07-12 18:52:18 +04:00
committed by GitHub
parent b7404373cf
commit fbe0e4c78c
8 changed files with 501 additions and 37 deletions

View File

@@ -77,6 +77,7 @@ end
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
Dir[Rails.root.join("spec/system/helpers/**/*.rb")].each { |f| require f }
Dir[Rails.root.join("spec/system/page_objects/**/base.rb")].each { |f| require f }
Dir[Rails.root.join("spec/system/page_objects/**/*.rb")].each { |f| require f }
@@ -286,6 +287,7 @@ RSpec.configure do |config|
.tap do |options|
apply_base_chrome_options(options)
options.add_argument("--window-size=1400,1400")
options.add_preference("download.default_directory", Downloads::FOLDER)
end
Capybara.register_driver :selenium_chrome do |app|
@@ -348,6 +350,7 @@ RSpec.configure do |config|
config.after(:suite) do
FileUtils.remove_dir(concurrency_safe_tmp_dir, true) if SpecSecureRandom.value
Downloads.clear
end
config.around :each do |example|