-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor MailingLists::Subscribers to make it faster #3128
Refactor MailingLists::Subscribers to make it faster #3128
Conversation
24fbab5
to
a7867be
Compare
Das script und die zahlen von der PBS sollten wir wahrscheinlich vor dem merge noch entfernen |
8a114a5
to
e4a68ec
Compare
e4a68ec
to
303b1e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Etwas Feedback zu den Nebenschauplätzen, die grosse SQL Änderung habe ich nicht überprüft 🤯
303b1e3
to
7af9b8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
```ruby require "optparse" options = {} OptionParser.new do |opt| opt.on("--offset OFFSET") { |o| options[:offset] = o } opt.on("--limit LIMIT") { |o| options[:limit] = o } end.parse! def now = Process.clock_gettime(Process::CLOCK_MONOTONIC) require_relative "config/environment" branch = `git symbolic-ref HEAD | sed -e 's,.*/,,'`.strip offset = options.fetch(:offset, 0).to_i limit = options.fetch(:limit, 10).to_i database = ActiveRecord::Base.connection.instance_variable_get(:@config)[:database] batch_size = limit / 10 filename = "list-performance-#{database}-#{branch}-#{offset}-#{limit}.csv" puts "Writing to #{filename}" File.open(filename, "w") do |file| file.write CSV.generate_line(%w[id people seconds]) MailingList.offset(offset).limit(limit).find_each.with_index do |list, index| puts "#{index} of #{limit}" if (index % batch_size) == 0 file.flush if (index % batch_size) == 0 start = now size = list.people.size file.write CSV.generate_line([list.id, size, (now - start).round(1)]) end end ```
dedcb78
to
2cbf413
Compare
Das script steht nun in der commit message drin statt als file im repo 🙃 |
Nicht wirklich, oder? 🙈 Was spricht dagegen, das im Repo abzulegen? Im Commit wird es sicher nie mehr gefunden, da wäre löschen wohl noch die bessere Option. 🥇 für die verkehrte Verwendung von Git. |
No description provided.