Skip to content
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

Hide deliveries column if there are no deliveries #417

Merged
merged 1 commit into from
Mar 11, 2016

Conversation

paroga
Copy link
Member

@paroga paroga commented Mar 6, 2016

For foodcoops which do not use the delivery feature the column occupies
space in the table, which could be user better with something else.

For foodcoops which do not use the delivery feature the column occupies
space in the table, which could be user better with something else.
@wvengen
Copy link
Member

wvengen commented Mar 7, 2016

Great!
I'm wondering whether this triggers two database calls for Delivery.any?, or whether it's cached.

@paroga
Copy link
Member Author

paroga commented Mar 8, 2016

The following output shows only one SELECT COUNT(*) FROM "deliveries":

Started GET "/f/finance/invoices" for 10.0.2.2 at 2016-03-08 03:41:03 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Finance::InvoicesController#index as HTML
  Parameters: {"foodcoop"=>"f"}
  RailsSettings::CachedSettings Load (1.8ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.ignore_browser_locale"]]
  CACHE (0ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.ignore_browser_locale"]]
Set locale to de
  User Load (2ms)  SELECT  "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = ? LIMIT 1  [["id", 1]]
  RailsSettings::ScopedSettings Load (2.3ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."thing_type" = ? AND "settings"."thing_id" = ? AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["thing_type", "User"], ["thing_id", 1], ["var", "profile"]]
  RailsSettings::ScopedSettings Load (5.1ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."thing_type" = ? AND "settings"."thing_id" = ? AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["thing_type", "User"], ["thing_id", 1], ["var", "messages"]]
  RailsSettings::ScopedSettings Load (1.7ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."thing_type" = ? AND "settings"."thing_id" = ? AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["thing_type", "User"], ["thing_id", 1], ["var", "notify"]]
  RailsSettings::CachedSettings Load (1.9ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.time_zone"]]
  RailsSettings::CachedSettings Load (1.8ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.currency_unit"]]
  RailsSettings::CachedSettings Load (1.6ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.currency_space"]]
   (1.2ms)  SELECT COUNT(*) FROM "invoices"
  CACHE (0ms)  SELECT COUNT(*) FROM "invoices"
   (2.1ms)  SELECT COUNT(*) FROM "deliveries"
  Invoice Load (242.1ms)  SELECT  "invoices".* FROM "invoices"  ORDER BY date DESC LIMIT 20 OFFSET 0
  Supplier Load (3.1ms)  SELECT "suppliers".* FROM "suppliers" WHERE "suppliers"."id" IN (1)
  Delivery Load (1.8ms)  SELECT "deliveries".* FROM "deliveries" WHERE "deliveries"."invoice_id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  Order Load (1.8ms)  SELECT "orders".* FROM "orders" WHERE "orders"."invoice_id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  CACHE (0ms)  SELECT COUNT(*) FROM "deliveries"
  Group Load (2.4ms)  SELECT "groups".* FROM "groups" INNER JOIN "memberships" ON "groups"."id" = "memberships"."group_id" WHERE "memberships"."user_id" = ?  [["user_id", 1]]
  CACHE (0ms)  SELECT COUNT(*) FROM "deliveries"
  CACHE (0ms)  SELECT COUNT(*) FROM "deliveries"
  CACHE (0.2ms)  SELECT COUNT(*) FROM "deliveries"
  CACHE (0.1ms)  SELECT COUNT(*) FROM "deliveries"
  CACHE (0.2ms)  SELECT COUNT(*) FROM "deliveries"
  CACHE (0ms)  SELECT COUNT(*) FROM "deliveries"
  Supplier Load (2ms)  SELECT  "suppliers".* FROM "suppliers" WHERE "suppliers"."id" = ? LIMIT 1  [["id", 1]]
  CACHE (0.2ms)  SELECT COUNT(*) FROM "deliveries"
  CACHE (1.7ms)  SELECT COUNT(*) FROM "deliveries"
  CACHE (0ms)  SELECT COUNT(*) FROM "deliveries"
  Rendered finance/invoices/_invoices.html.haml (675.9ms)
  Rendered finance/invoices/index.html.haml within layouts/application (737.9ms)
  RailsSettings::CachedSettings Load (4.7ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.custom_css"]]
  RailsSettings::CachedSettings Load (1.8ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.use_nick"]]
  RailsSettings::CachedSettings Load (2.4ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.homepage"]]
  RailsSettings::CachedSettings Load (14.4ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.name"]]
  CACHE (0ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.homepage"]]
  RailsSettings::CachedSettings Load (1.8ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.help_url"]]
  RailsSettings::CachedSettings Load (1.1ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.use_wiki"]]
  RailsSettings::CachedSettings Load (1.7ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.use_messages"]]
  RailsSettings::CachedSettings Load (1.6ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.page_footer"]]
  RailsSettings::CachedSettings Load (1.9ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.foodsoft_url"]]
  CACHE (0ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.foodsoft_url"]]
  CACHE (0.1ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.page_footer"]]
  CACHE (0ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.name"]]
  CACHE (0ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.homepage"]]
  Rendered layouts/_footer.html.haml (52.5ms)
  RailsSettings::CachedSettings Load (1.8ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = ?  ORDER BY "settings"."id" ASC LIMIT 1  [["var", "foodcoop.f.webstats_tracking_code"]]
  Rendered layouts/_header.html.haml (1487ms)
Completed 200 OK in 3032ms (Views: 2532.4ms | ActiveRecord: 310.6ms)

@wvengen
Copy link
Member

wvengen commented Mar 11, 2016

Thanks :)

wvengen added a commit that referenced this pull request Mar 11, 2016
Hide deliveries column if there are no deliveries
@wvengen wvengen merged commit b56df39 into foodcoops:master Mar 11, 2016
@wvengen wvengen added this to the 4.5 milestone Mar 11, 2016
@paroga paroga deleted the deliveries_col branch March 11, 2016 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants