なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2018/07/27)

2018/07/27分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activesupport/CHANGELOG.md


Add cpu_time, idle_time, and allocations to Event

activesupport/lib/active_support/notifications/instrumenter.rbactivesupport/lib/active_support/subscriber.rbの修正です。

ActiveSupport::Notifications::Eventが保持するデータに、cpu time, idle time, 及びオブジェクトの数を追加しています。

オブジェクトの数はGC.stat:total_allocated_objectsを使用しています。GC.statの結果に:total_allocated_objectsが無いJRubyでは0を返すようになっています。


Merge pull request #33451 from rails/event-object-subscription

activesupport/lib/active_support/notifications/fanout.rbactivesupport/lib/active_support/notifications/instrumenter.rbの修正です。

ActiveSupport::Notifications.subscribeのブロックに指定したパラメータが一つだけだった場合、ActiveSupport::Notifications::Eventインスタンスをブロックに渡すよう修正しています。

元々、ActiveSupport::Notifications.subscribeのブロックに渡されるパラメータはeventに関する各種情報(eventの名前、開始時刻、終了時刻、payload等)で、ActiveSupport::Notifications::Eventインスタンスが必要な場合、それらのパラメータを使って、明示的にオブジェクトの生成処理を行う必要がありました。

この対応により、ActiveSupport::Notifications::Eventインスタンスが必要な場合、ActiveSupport::Notifications.subscribeのブロックから直接受け取れるようになっています。

# before
ActiveSupport::Notifications.subscribe('wait') do |*args|
  @event = ActiveSupport::Notifications::Event.new(*args)
end

ActiveSupport::Notifications.instrument('wait') do
  sleep 1
end

@event.duration # => 1000.138
# after
ActiveSupport::Notifications.subscribe('wait') do |event|
  @event = event
end

ActiveSupport::Notifications.instrument('wait') do
  sleep 1
end

@event.duration # => 1000.138

I cannot spell

activesupport/CHANGELOG.mdの修正です。

artisanalarsenalにタイポしていたのを修正しています。


Log streaming downloads

activestorage/lib/active_storage/log_subscriber.rbの修正です。

service_downloadのaliasとして、service_streaming_downloadを定義して、streaming downloads実行時にログが出力されるようにしています。


Merge pull request #33441 from bogdanvlviv/remove-rubocop-comments-from-codebase

テストコード内で個別にrubocop:disable Performance/RedundantMergeを指定していたのを、そもそもテストについてはPerformance copの対象としないよう修正しています。


PostgreSQL 10 new relkind for partitioned tables (#31336)

PostgreSQLのpartitioned tablesについてのサポートを追加しています。

これにより、partitioned tablesで定義されたtableも、普通のtableやviewと同様にActive Recordから操作出来るようになっています。


Fix directly uploading zero-byte files

activestorage/app/assets/javascripts/activestorage.jsactivestorage/app/javascript/activestorage/file_checksum.jsの修正です。

Active Storageのdirecty uploadで0バイトのファイルがアップロード出来ないバグがあったのを修正しています。


Clarify condition

activestorage/app/javascript/activestorage/file_checksum.jsの修正です。

chunkをreadする必要かあるかどうかの条件文に、中括弧を追加し条件がわかりやすくなるよう修正しています。


Merge pull request #33434 from utilum/remove_testing_guide_comment

rails guideのTesting Rails Applicationsの修正です。

Rails meets Minitestの項にあるテストメソッド名についての説明から、不要なコメントを削除しています。