GithubHelp home page GithubHelp logo

openfoodfacts / open-prices Goto Github PK

View Code? Open in Web Editor NEW
28.0 7.0 8.0 2.47 MB

An open database of food prices - πŸ§ΎπŸ’ΈπŸ’°πŸ·οΈπŸ€‘πŸ½οΈ

License: GNU Affero General Public License v3.0

Dockerfile 1.18% Makefile 1.82% Python 78.78% HTML 17.82% Mako 0.27% Shell 0.13%
prices hacktoberfest

open-prices's People

Contributors

alexfauquette avatar alvarobertin avatar arturlange avatar dependabot[bot] avatar dq18 avatar fbtw avatar github-actions[bot] avatar openfoodfacts-bot avatar raphael0202 avatar raphodn avatar sudhanva-nadiger avatar teolemon avatar vjousse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

open-prices's Issues

An admin interface for moderators

Story

Admin / moderators could have an easy-to-use interface to make changes (edit or delete price, edit location data...).
Similar to the admin in Django.

Libraries

see below

Allow the current user to filter on own prices

Story

Currently the prices are available anonymously. There are filters available, but none on the "owner".

It would be interesting for the authenticated user to fetch prices that we're created by him (but not allow filtering on other owners to respect privacy) owner data is public, we can filter on any owner

Backup the database & generate data dump

We don't do any backup for now.

  • perform daily backups of the DB
  • generate a daily dump (JSONL) that is available for download to all users.
  • update the landing page (prices.openfoodfacts.org) to reflect the existence of this daily dump

Endpoint to get a proofs' prices

Story

Given a proof_id, it is currently not easily possible to get the related prices (and it's price_count).

We could add an extra filter on the PriceFilter, but there is a privacy risk for private proofs.
An alternative is to create a new route /proofs/<id>/prices and make sure that the authenticated user is the owner of the proof

Create a Proof model

Story

We will want to have each Price linked to a Proof.

  • for now it can be only an image
  • 1 proof can correspond to multiple prices (ex: receipt)

Add real session support

Currently, we use a single user table to store the associated token. It's not ideal as we can't be logged in on more than one device (error while uploading photos occur).

We should add a session table and migrate the tokens to the new table.

Create a Price model & create/fetch data

Story

  • Price model
  • create price
  • fetch prices (with filters)

How

The Price model should store the basic fields :

  • product_code
  • price
  • currency
  • location_osm_id & location_osm_type
  • date

Return product & location data

Story

When fetching prices, we currently get the product_id & location_id.
To avoid having to make additional queries, we would like to return the full Product & Location objects.

Note

Need to optimize queries to avoid N+1 calls to the DB

Store & sync the product categories from OFF

Story

To better compare products, the category is a good info to store

How ?

We could store the last category known in the categories_hierarchy field ?
Better : the full categories_tags list (what is the difference with categories_hierarchy ?)

image

Add an endpoint to delete a proof

Currently, we can't delete a proof once uploaded.

Endpoint: DELETE /api/v1/proofs/:proof_id

This endpoint should deny deleting proofs if:

  • some prices are associated with it
  • if the user is not the owner of the proof

🎯 What can i work on ? (open-prices)

What

Tasks

  1. ⭐ top issue πŸ„β€β™€οΈ good first issue
  2. πŸ“ Location
  3. Proofs βœ… Task
  4. βœ… Task πŸ“š Documentation

Make input easier

Make interesting and thought provoking visualization

  1. Categories Product data sync βœ… Task

Create a road to refresh/complete product data

No tasks being tracked yet.

Deploy Open Price Everywhere

  1. ✨ enhancement

Elsewhere

Product filter by category

Story

Following #154

We need to add a new filter capability to find only products of a certain category. Bonus : allow filtering by multiple categories as well.

But I'm not exactly sure how to proceed with the fastapi-filter library. I opened an issue : arthurio/fastapi-filter#556

Or maybe I'm missing something ? πŸ˜…

Possibility to store the product "shop label name"

Story

When adding a price, we usually have the product label (e.g. BANANE CRF BIO MH 5 FRUITS IMP) alongside.

This information could be useful, let's store it !

Price.product_label ? --> product_name

Extract data from proof images

Story

There is lots of interesting info in the proof images :

  • price tag : price, barcode
  • receipt : multiple prices, no barcodes nor EAN but a "product name", date, location
  • exif data : date & location ?

What if the server was able to do some image recognition, and return to the frontend all of that info ? 🀩

Challenges

Price tag

Receipt

Without the product EAN or barcode, how to link to the exact product in the OFF database ?

Image examples

Price tag Multiple price tags Receipt
05JD3g310N IMG_20240127_172140 receipt

Add an endpoint to update a price

We can't update prices, which starts to become cumbersome to users.

Add a PUT /api/v1/prices endpoint, that allows to update all price information.
The user should only be allowed to update his/her prices.

Improve location city mapping

Story

When a new location is added, we fill a couple of fields in our database.

For the city field it is a bit tricky, we currently look at ["village", "town", "city", "municipality"]

Is it the best way to do it ?

Import & sync the whole database with OFF

Story

Currently products are added in Open Prices on a per-scan basis, when a price is added.

What about having a list of the top 500 (or more ?) scanned products in Open Food Facts, and importing them in Open Prices.

We could then display them in the frontend, and nudge users to add prices for these products, displaying their price count :)

Endpoint to get the list of top contributors

Story

It would interesting to display the list of contributors, ranked by number of prices added.

For this, we need:

  • an endpoint on the User model
  • a price_count field that calculates the number of prices added (real-time ? or updated every night ?)

Expand the GDPR import script for new stores

Problem

Expand the GDPR import script (#209) for more stores

Obstacles to turning the GDPR import script into a self-service system

No tasks being tracked yet.

Part of

Manage discounted prices

Story

We currently have a price field (mandatory, decimal) for all the items added to the database..

But for products currently discounted, we need an easy way to store the discount-related information.

I see 2 solutions :

1) The price field always stores the current price (full or discounted depending on the item)

  • a boolean field price_is_discounted which would be False by default
  • an extra decimal field price_without_discount which would be available to fill if the above field is True

2) The price field always stores the full price

  • a boolean field price_is_discounted which would be False by default
  • an extra decimal field price_discounted which would be available to fill if the above field is True

Return the price per quantity

Story

We have the price (stored in Price.price) and we have the quantity (stored in Product.product_quantity).
It would interesting to compute and return the price per kg or L.

  • how to differentiate between kg quantities & L quantities ? an additional product field to get from OFF to help us differentiate beverages ?
  • or should we leave the frontend to compute & display this info ?

Server timezone

Story

There seems to be an issue (not sure if a backend or a frontend problem), new prices show up with "1h ago" instead of "1m ago".

I suspect that the timestamps in the backend are stored without timezone.

Tutorials to help contributors

Story

  • how to add a single price
  • how to add multiple prices (from a shop shelf)
  • how to add multiple prices (from a receipt)

Create a Location model

Story

We'll store the price's location info separately.
We'll fetch the data from OpenStreetMap.

Some fields to store :

  • osm_id & osm_type
  • osm_display_name
  • osm_lat
  • osm_lon
  • other ?

Tasks

  • Location model
  • on Price create, check if a Location already exists, or create a new on + link it to the Price
  • on Location create, fetch metadata from OSM
  • api endpoint ?

Clarify the product quantity unit (g or mL)

Story

For each new product we fetch from Open Food Facts its product_quantity, a normalized number in g or mL.

We need to find a way to know if the product is a beverage (mL), or solid (g), so that we can display the information accordingly in the frontend (price per kg or price per L).

Linked to #77

Easily get the last known price of a product

Story

What is the best strategy to efficiently get the last known price of a product ?

Why ?

In the frontend, there are various places where we could display this information to the user :

  • in the list of products, along with it's price count - see #123
  • when a new price is being added, and the product bar code is scanned, we display information about the product
  • ?

Add support for moderators

Moderators are special users that will be allowed to delete/update prices or proofs of other users.
This is necessary to ensure database quality.

Tasks:

  • create a new is_moderator field in the users table : #183
  • allow moderators to edit proofs : #235
  • allow moderators to delete proofs (without prices) : #197
  • allow moderators to edit prices : #259
  • allow moderators to delete prices : #260

Proof: manage webp uploads

Story

We use mimetypes.guess_extension() to define the extension of the uploaded file

But image/webp doesn't seem to be managed by the server (nor my local environment - Ubuntu 22.04)

Price filter by proof id

Story

In the frontend, it would be useful for users to fetch prices corresponding to a specific proof

Find ways to fill idle time contributing to Open Prices

What

  • Find ways to fill idle time contributing to Open Prices

Why

  • The times of the week where you have both a price and the barcode together are scarce.
  • We need to exit that paradigm if we want to grow contribution and people coming back daily

How: ideas welcome

  • Snap shelves photos, add data later. All 2 tasks can be done at different times
  • Split bulk product addition
    • Create a basket in your open prices account by scanning all products (introduce a transient shopping session object)
    • Take a photo of the receipt stored in your open prices account
    • Link both at a later time
    • All three tasks can be done at different times

Create a Product model

Story

We'll store the price's product info separately.
We'll fetch the data from OpenFoodFacts.

Some fields to store :

  • code
  • in_off ?
  • off_db (off or opf or obf or opff)
  • off_name
  • off_image_url
  • other ? quantity, categories

Code improvements (tooling, async...)

Story

For the v1 we went a bit fast, here is a list of known improvements :

  • #221
  • schema: add field descriptions (pydantic) & examples
  • typing: add return types (especially in crud.py & utils.py)
  • background tasks: avoid passing db (see this discussion)
  • tests: teardown data between each test, add more tests
  • tests: use PostgreSQL instead of SQLite
  • documentation: improve it (ex: docker), add docstring

Script to refresh Product data

Story

Currently we fetch data from OpenFoodFacts when a price is added and the product is not yet in our database.
But if the product info changes on OFF, or if we add new fields to store, the existing products are not updated.

  • this script could run regularly, say every week
  • we'll need something similar for OpenStreetMap locations ?

New Product price_count field

Story

Idea of creating a new field Product.price_count.

Helpful for :

  • sorting products by most prices
  • displaying the price count in the product details card

How to update :

  • incremented synchronously on each new price

Better sync the product brands from OFF

Story

When we sync the products from OFF, we currently fetch the raw brands field.

But if we fetched instead the brands_tags we could have better search & filter capabilities for the Frontend.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.