Giter Club home page Giter Club logo

supermarket-tracker's Introduction

Supermarket Tracker

Tracks supermarket prices across New Zealand online supermarkets.

Currently Countdown prices can be fetched, with the application fetching both Countdown Mt Eden and Woolsworth Hornby store prices.

Starting the application

  • Setup relevant environment variables (a .env file can be used for convenience, see .env.example)
  • Run a Postgres instance with a blank supermarket_tracker database created (e.g., with docker compose up -d)
    • The app will initialize all tables for you when first run

CLI Usage

supermarket-tracker

Usage:
    supermarket-tracker [OPTIONS] [SUBCOMMAND]

Options:
    --supermarket <SUPERMARKET>     The supermarket to run price tracking on [countdown]
    --no-insert                     Optionally skips insertion of new products/prices to database

Architecture

Core application is written in Rust. Read more in the ARCHITECTURE.md document.

Using with Docker

Docker can be used to host the Postgres database, and perform all the initial work of setup.

To use, ensure you have a .env file (if you don't, simply cp .env.example .env) and run docker compose up -d to start the services. This will expose a Postgres database on port 5432 of the host machine.

To stop, use docker compose down to stop all the containers, and docker compose down --volumes to delete the volumes as well.

How much data is tracked?

I currently have around ~800,000 price points from ~23,000 products tracked since October 2022.

If this data would be of use, please contact me. I have mostly used it for my own fun statistical analysis, and comparing data against what Stats NZ produces.

Migrating Docker Containers Between Hosts

I've had some trouble finding resources for this online, so I thought posting these instructions would be helpful.

Replace $CONTAINER_NAME, $DATABASE_NAME and $DOCKER_FILENAME accordingly for your system.

  1. On machine A, run docker exec -it $CONTAINER_NAME bash
  2. Once in a bash terminal in the docker container, run pg_dumpall -c -U postgres | gzip > ./tmp/dump_$(date +"%Y-%m-%d_%H_%M_%S").gz
  3. Verify file looks good in the docker container, and note the location of it (noted as $DOCKER_FILENAME).
  4. Transfer from docker container to host with docker cp $CONTAINER_NAME:/tmp/$DOCKER_FILENAME /tmp/$DOCKER_FILENAME
  5. Now transfer the file over to the host, using whatever means you prefer.
  6. We now use $CONTAINER_NAME to refer to the fresh postgres instance created. This instance must have an empty $DATABASE_NAME created (e.g., with docker compose up -d).
  7. Use docker cp ./$DOCKER_FILENAME$ $CONTAINER_NAME$:/tmp/$DOCKER_FILENAME$
  8. docker exec -it $CONTAINER_NAME bash
  9. gunzip /tmp/$DOCKER_FILENAME | psql -U postgres -d $DATABASE_NAME
  10. All done!

Cheers to https://stackoverflow.com/questions/24718706/backup-restore-a-dockerized-postgresql-database for the suggestions.

supermarket-tracker's People

Contributors

overhash avatar

Stargazers

 avatar  avatar

Watchers

 avatar

supermarket-tracker's Issues

Remove duplicate retrieved products in countdown list

Currently there is about a ~2000 non-unique products when retrieving all_products.

This is because categories may contain overlapping products. During get_all_products we should ensure to remove these duplicate products.

For a sample, sku 243682 with the following product information:

{
  "name": "angel bay veggie burger patties ",
  "barcode": "9419411000003",
  "sku": "243682",
  "per_unit_price": 1300
}

has duplicates under page 6 of /shop/browse/frozen (Frozen category) and also under page 14 of /shop/browse/christmas (Christmas category).

While this behavior doesn't have catastrophic consequences, it inflates the product count and means extra work later in the program.

Attach suggestions when using error-stack

Some basic suggestions like when an invalid parse option is found for a user passing the --supermarket option (e.g., --supermarket countdown when the user meant to type --supermarket Countdown) could be provided.

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.