Connecting food cooperatives

Yes, standard data formats would be nice to have. Until common standards emerge from widely used best practices we can simply translate between different data formats.

What’s not clear to me is how a replication protocol would work :confused:

Is it possible with the current OFN rest API to get the products that have been modified since some (last sync) timestamp? How to detect deletes? What is soft delete mentioned in the API docs?

Most of the time two systems connect they will already be almost in sync. It would be great to quickly cheaply detect that… Any ideas?

@wvengen afaics you do quite some sophisticated data synchronisation between the central product database and various foodsoft instances. Do you delete and reimport everything to catch deleted products? Are there also (two-way-sync) changes uploaded from the instance to the central database?

@orangeman I am a programmer / designer community activist / CMS person
interested in using OFN here in the states for local food emphasis in
Colorado and upstate NY initially.

I have been working on getting a local copy of the software running via
docker or vagrant…

Once I have a local copy to experiment with, I’d be happy to construct a
query for you against the database that could be used with the rest API for
our future specialized needs like you are requiring…

all best good vibes to your work!
Greg

1 Like

Thx @NorthernColorado Sounds great!

How would you go about this?
extending the rails app rest api?
or build some kind of api node
that uses the same postgres?

Are you using the ansible playbooks to build the docker images?
Currently I’m stuck at the last webserver ansible task: update unicorn
it errors: "Could not find the requested service "‘unicorn_openfoodnetwork’"
any idea? @pmackay

Edit: ansible debian topic Connecting food cooperatives

Hi Orangeman…

yes, my thoughts were to add a new db class that the api talks to, and make that result available throygh the rest api…

looking here for how ‘unicorn_openfoodnetwork’ could be named as a service.
what order did you get that error in? were there any other steps completed beforehand?

thanks
Greg

ref1: https://github.com/openfoodfoundation/ofn-install/tree/master/playbooks

ref2: http://www.mzoo.org/open-food-network-on-new-vps/

trying product post example from spree product api docs
http://guides.spreecommerce.org/api/products.html#create

curl -X POST -H “X-Spree-Token: abc…”
https://www.fairteil.de/api/products?product[name]=Headphones&product[price]=100

the api responds that supplier is missing but supplier is not part of spree products, right? At least the product json from the api does not contain a supplier. Apending product[supplier]=foo seems to be ignored by the api

Is anyone using the product rest api so far?
write a separate ofn product api?
or decorate the spree api?

it seems to work! with supplier_id instead of supplier

curl -X POST -H “X-Spree-Token: xyz” “http://localhost:3000/api/products?product[name]=Headphones&product[price]=100&product[supplier_id]=2&product[variant_unit]=items&product[variant_unit_name]=kiste&product[unit_value]=1&product[primary_taxon_id]=5

How to detect (and handle) the case when the same product changed in between a sync on both sides?

@NorthernColorado @orangeman hi guys, could I please suggest to create separate threads, or perhaps better to raise GH issues in ofn-install for problems with the install process? Its certainly not strongly related to this thread so would be better pulled out.

Hi orangeman

I was reading through these yesterday to help answer your question…

http://guides.spreecommerce.org/api/products.html

https://spreecommerce.com/blog/updated-rest-api

http://guides.spreecommerce.org/api/variants.html

it sounds like you may need to add a supplier valiue or tell the api to
stop asking for it…

We shall figure it out!
G

Here a product data sync thread
Product data sychronization

I’ve mentioned the Diaspora project here already:

It is a decentralized social network.
Perhaps this could be very interesting to look at in terms of decentralization and privacy for the OFN project as well.