Maikel Linke dc5302ca08 Speed up database queries and make them scale
This commit makes use of three ActiveRecord features:

1. Using `select` instead of `all.map` enables ActiveRecord to nest one
select into the other, resulting in one more efficient query instead of
two.

2. Using `find_each` saves memory by loading records in batches.
https://api.rubyonrails.org/classes/ActiveRecord/Batches.html#method-i-find_each

3. Using `pluck` creates only an array, avoiding loading all the other
columns of the records into objects.

Running this on the current Canadian database, fixes the following
variant overrides:

```
[]
[]
[]
[]
[]
[]
[925, 924, 966, 965]
[]
[]
[]
[]
[462,
 863,
 464,
 822,
 949,
 947,
 944,
 939,
 942,
 946,
 945,
 943,
 438,
 937,
 938,
 941,
 940,
 467,
 952,
 875,
 453,
 953,
 454,
 951,
 487,
 460,
 457,
 528,
 527,
 486,
 459,
 458,
 461,
 529,
 530,
 950,
 642,
 384,
 380,
 643,
 385,
 381,
 644,
 386,
 382,
 960,
 959,
 379,
 640,
 377,
 375,
 532,
 639,
 376,
 374,
 646,
 390,
 389,
 637,
 406,
 408,
 647,
 391,
 393,
 633,
 396,
 400,
 398,
 645,
 388,
 387,
 648,
 394,
 392,
 536,
 632,
 399,
 397,
 395,
 634,
 403,
 401,
 635,
 404,
 402,
 636,
 407,
 405,
 535,
 534,
 638,
 410,
 409,
 948,
 533,
 537,
 531,
 877,
 880,
 894,
 893,
 672,
 671,
 673,
 674,
 703,
 714,
 715,
 716,
 717,
 862,
 864,
 879,
 876,
 865,
 881,
 878,
 463,
 954,
 866,
 823,
 957,
 958,
 955,
 956,
 899,
 897]
[]
[969]
```
2018-10-25 11:33:14 +11:00
2015-12-24 11:44:12 +11:00
2018-09-27 13:33:09 +10:00
2012-03-27 10:10:26 +11:00
2018-10-09 17:06:59 +11:00
2015-01-09 15:30:49 +11:00
2015-11-05 11:09:22 +11:00
2016-02-09 06:11:13 +00:00
2012-12-18 15:56:54 +11:00
2018-10-04 18:43:30 +02:00

Build Status Code Climate View performance data on Skylight

Open Food Network

The Open Food Network is an online marketplace for local food. It enables a network of independent online food stores that connect farmers and food hubs (including coops, 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!

Contributing

If you are interested in contributing to the OFN in any capacity, please introducing yourself on Slack, and have a look through our Contributor Guide

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.

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.

Credits

Licence

Copyright (c) 2012 - 2018 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%