• Adam Hegyi's avatar
    Improve performance of audit events CSV export · 52cd0b7e
    Adam Hegyi authored
    For search UI, the audit events scope is limit by pagination. This does
    not exhibit the same problem with CSV export where scope does not
    have set limit (we use file size limit as the stopping mechanism).
    
    Preloading associated records, hence, requires to be performed in
    batches to avoid overloading memory. BatchLoader cache was designed to
    hold data for one web request, which in our case might yield significant
    amount of user records. To keep the memory growth under control, we're
    clearing up the cached data after each iteration (i.e. after 1K
    records).
    
    A fix for `MissingAttribute` error when calling `select` without
    `details` field is also introduced. This is caused by the call back
    method to initialize `details` after AR model loaded from database. This
    change allows the following usage: `AuditEvent.select(:id).first`.
    Co-authored-by: default avatarTan Le <tle@gitlab.com>
    52cd0b7e
preloader.rb 871 Bytes