• Arturo Herrero's avatar
    Reduce 1 query count using `map` instead of `pluck` · 848e6b2d
    Arturo Herrero authored
    map
    
      Service Load (0.7ms)  SELECT "services".* FROM "services" WHERE
        "services"."template" = $1 AND "services"."type" IN ($2, $3, $4, $5,
        $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
        $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32,
        $33, $34, $35, $36, $37, $38, $39)
      ↳ app/models/service.rb:270:in `map'
      Rendering admin/services/index.html.haml within layouts/admin
      CACHE Service Load (0.1ms)  SELECT "services".* FROM "services" WHERE
        "services"."template" = $1 AND "services"."type" IN ($2, $3, $4, $5,
        $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
        $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32,
        $33, $34, $35, $36, $37, $38, $39)
      ↳ app/views/admin/services/index.html.haml:13:in `sort_by'
    
    pluck
    
       (0.6ms)  SELECT "services"."type" FROM "services" WHERE
         "services"."template" = $1 AND "services"."type" IN ($2, $3, $4,
         $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18,
         $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31,
         $32, $33, $34, $35, $36, $37, $38, $39)
      ↳ app/models/service.rb:270:in `create_nonexistent_templates'
      Rendering admin/services/index.html.haml within layouts/admin
      Service Load (0.5ms)  SELECT "services".* FROM "services" WHERE
        "services"."template" = $1 AND "services"."type" IN ($2, $3, $4, $5,
        $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
        $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32,
        $33, $34, $35, $36, $37, $38, $39)
      ↳ app/views/admin/services/index.html.haml:13:in `sort_by'
    848e6b2d
service.rb 10.6 KB