Pau Perez 060530cda8 Do not fetch VOs with deleted variant
In the line below we filter them out in Ruby so it's a waste of
resources. The fundamental difference is that `#includes` and
`#references` results in LEFT JOINs, whereas `#joins` results in INNER
JOIN, and because there's a default scope on `deleted_at IS NULL`, these
are not included in the result set.

This however, requires us to move away from the current algorithm but
unfortunately we can't refactor it completely yet.

Before:

```sql
SELECT *
  FROM "variant_overrides"
  LEFT OUTER
  JOIN "spree_variants"
    ON "spree_variants"."id"              =  "variant_overrides"."variant_id"
   AND "spree_variants"."deleted_at" IS NULL
  LEFT OUTER
  JOIN "spree_products"
    ON "spree_products"."id"              =  "spree_variants"."product_id"
   AND "spree_products"."deleted_at" IS NULL
 WHERE "variant_overrides"."permission_revoked_at" IS NULL
   AND "variant_overrides"."hub_id" IN (
    SELECT "enterprises"."id"
      FROM "enterprises"
    INNER
      JOIN "enterprise_roles"
        ON "enterprise_roles"."enterprise_id" =  "enterprises"."id"
    WHERE (enterprise_roles.user_id          =  ?)
      AND (sells                             != 'none')
 ORDER BY name)
```

After:

```sql
SELECT "variant_overrides".*
  FROM "variant_overrides"
 INNER
  JOIN "spree_variants"
    ON "spree_variants"."id"              =  "variant_overrides"."variant_id"
   AND "spree_variants"."deleted_at" IS NULL
 INNER
  JOIN "spree_products"
    ON "spree_products"."id"              =  "spree_variants"."product_id"
   AND "spree_products"."deleted_at" IS NULL
 WHERE "variant_overrides"."permission_revoked_at" IS NULL
   AND "variant_overrides"."hub_id" IN (
    SELECT "enterprises"."id"
      FROM "enterprises"
    INNER
      JOIN "enterprise_roles"
        ON "enterprise_roles"."enterprise_id" =  "enterprises"."id"
    WHERE (enterprise_roles.user_id          =  ?)
      AND (sells                             != 'none')
 ORDER BY name)
```

This is covered in the test suite by
spec/controllers/admin/variant_overrides_controller_spec.rb:72. It keeps
passing so we're good to go.
2021-02-01 14:47:51 +01:00
2015-12-24 11:44:12 +11:00
2021-02-01 14:47:51 +01:00
2021-01-28 21:51:47 +00:00
2012-03-27 10:10:26 +11:00
2020-10-16 16:03:26 +11:00
2019-06-25 11:18:48 +02:00
2015-01-09 15:30:49 +11:00
2020-01-10 08:59:44 +11:00
2020-12-01 15:16:39 +00:00
2012-12-18 15:56:54 +11:00
2020-12-09 12:31:36 -08:00
2020-12-09 12:31:36 -08:00

Build Status Code Climate

Open Food Network

The Open Food Network is an online marketplace for local food. It enables a network of independent online food stores that connects farmers and food hubs (including co-ops, online farmers markets, independent food businesses, etc) with individuals and local businesses. It gives farmers and food hubs an easier and fairer way to distribute their food.

Supported by the Open Food Foundation and a network of global affiliates, we are proudly open source and not-for-profit - we're trying to seriously disrupt the concentration of power in global agri-food systems, and we need as many smart people working together on this as possible.

We're part of global movement - get involved!

  • Join the conversation on Slack. Make sure you introduce yourself in the #general channel and join #dev for all tech-related topics.
  • Head to https://openfoodnetwork.org for more information about the global OFN project.
  • Check out the User Guide for a list of features and tutorials.
  • Join our discussion forum.

Contributing

If you are interested in contributing to the OFN in any capacity, please introduce yourself on Slack, and have a look through the OFN Handbook.

Our GETTING_STARTED and CONTRIBUTING guides are the best place to start for developers looking to set up a development environment and make contributions to the codebase.

Hacktoberfest 🎉

Are you participating in Hacktoberfest? Go check out our Welcome New Developers project board! We have curated all issues we consider to be a good starting point for new members of the community and categorized them by skills and level of complexity. Have a look and pick the one you would prefer working on!

Provisioning

If you're interested in provisioning a server, see ofn-install for the project's Ansible playbooks.

We also have a Super Admin Guide to help with configuration of new servers.

Testing

If you'd like to help out with testing, please introduce yourself on the #testing channel on Slack and download the ZenHub browser extension to view the development pipeline.

We use BrowserStack as a manual testing tool. BrowserStack provides open source projects with unlimited and free of charge accounts. A big thanks to them!

Licence

Copyright (c) 2012 - 2020 Open Food Foundation, released under the AGPL licence.

Description
Connect suppliers, distributors and consumers to trade local produce.
Readme 157 MiB
Languages
Ruby 74.7%
Haml 9.4%
CoffeeScript 7.3%
SCSS 4.5%
JavaScript 3.6%
Other 0.4%