-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created serde_config * Setting up db in env file (#117) * Updated version and added README to subproject * Improved unwrap and test loging * Allowed ItemError for advanced items * Fixed Advanced items test * Improved README * Fixed icons * Removed T.o.C * Centered title * Updated Changelog and version number * Small change for CHANGELOG * Removing debug * Implemented suggested change * Removed unnecessary braces * Updated .gitattributes * make Json transparent in the error * Improved README --------- Co-authored-by: Pepe Márquez Romero <pepe.marquezromero@protonmail.com>
- Loading branch information
Showing
19 changed files
with
544 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copy this file as your .env | ||
POSTGRES_DB=vinted-rs | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_USER=postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ Cargo.lock | |
/**/results/ | ||
docker/query.sh | ||
|
||
src/tests/output | ||
src/tests/output | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
include .env | ||
|
||
db: | ||
docker run --rm -d --name postgres -p 5432:5432 \ | ||
-e POSTGRES_DB=vinted-rs \ | ||
-e POSTGRES_USER=postgres \ | ||
-e POSTGRES_PASSWORD=postgres \ | ||
-e POSTGRES_DB=$(POSTGRES_DB) \ | ||
-e POSTGRES_USER=$(POSTGRES_USER) \ | ||
-e POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) \ | ||
postgres:latest | ||
|
||
|
||
diesel: | ||
DATABASE_URL=postgres://postgres:postgres@localhost/vinted-rs diesel migration run | ||
DATABASE_URL=postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@localhost/$(POSTGRES_DB) diesel migration run | ||
stop: | ||
docker kill postgres | ||
|
||
clippy: | ||
cargo clippy --all-features | ||
cargo clippy --all-features | ||
|
||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,117 @@ | ||
# Vinted-rs: A Vinted API wrapper | ||
<div align="center"> | ||
|
||
# Vinted-rs: A Vinted API wrapper in Rust | ||
|
||
[![github]](https://github.com/TuTarea/vinted-rs/) [![crates-io]](https://crates.io/crates/vinted-rs) [![docs-rs]](https://docs.rs/vinted-rs/latest/vinted_rs/) | ||
|
||
[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github | ||
[crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust | ||
[docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs | ||
|
||
## Table of Contents | ||
|
||
- [Vinted-rs: A Vinted API wrapper](#vinted-rs-a-vinted-api-wrapper) | ||
- [Table of Contents](#table-of-contents) | ||
- [Installation](#installation) | ||
- [DB setup](#db-setup) | ||
- [Create a migration](#create-a-migration) | ||
- [Run a Docker container with PostgreSQL](#run-a-docker-container-with-postgresql) | ||
- [Run migrations](#run-migrations) | ||
- [Stop DB](#stop-db) | ||
- [Running Tests](#running-tests) | ||
</div> | ||
|
||
## Installation | ||
|
||
Via `cargo` you can add the library to your project's `Cargo.toml` | ||
|
||
```toml | ||
[dependencies] | ||
vinted-rs = "0.9.1" | ||
vinted-rs = { version = "0.10.0", | ||
#features = ["advanced_filters", "redis"] | ||
} | ||
``` | ||
|
||
## DB setup | ||
## Features | ||
|
||
| Feature | Description | Example | | ||
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------- | | ||
| [Advanced Filters](#advanced-filters) | Uses the data pulled by the [scrapping module](./scrapping/vinted-db-feeder/), which is stored in the diesel [migrations](./migrations/) folder. | [✅](./examples/filter_example/) | | ||
| [Redis](#redis) | Allows recovered results to be cached using a Redis instance | ❌ | | ||
|
||
### Advanced filters | ||
|
||
> This feature requires [setting up a Postgres Database](#database-set-up) <code><img width="3%" src="https://raw.githubusercontent.com/yurijserrano/Github-Profile-Readme-Logos/refs/heads/master/databases/postgresql.svg"></code> | ||
Uses the data pulled by the [scrapping module](./scrapping/vinted-db-feeder/), which is stored in the diesel [migrations](./migrations/) folder. | ||
|
||
#### Environment set-up | ||
|
||
1. Copy the `.env.example` | ||
|
||
```sh | ||
cp .env.example .env | ||
``` | ||
|
||
2. Modify the variables to your liking | ||
|
||
#### Database set-up | ||
Advanced filtering features must require this setup before running. | ||
|
||
- First start installing diesel-cli (in order to run the migrations in PostgreSQL database) | ||
1. ⚠️ `diesel-cli` installation may fail if you do not have `libpq` library installed. To install `libpq`, just install PostgreSQL package on your machine. | ||
|
||
⚠️**Very important:** diesel-cli installation may fail if you do not have `libpq` library installed. | ||
- In `Arch` based is only necessary to install this package. | ||
|
||
To install `libpq`, just install PostgreSQL package on your machine. | ||
```bash | ||
sudo pacman -S postgresql-libs | ||
``` | ||
|
||
In `Arch` based is only necessary to install this package. | ||
- In `Debian` based distributions is only necessary to install this package. | ||
|
||
```bash | ||
sudo pacman -S postgresql-libs | ||
``` | ||
```bash | ||
sudo apt install libpq-dev | ||
``` | ||
|
||
In `Debian` based distributions is only necessary to install this package. | ||
2. Install `diesel-cli` in order to run the migrations in PostgreSQL database | ||
|
||
```bash | ||
cargo install diesel_cli --features=postgres --no-default-features | ||
``` | ||
|
||
```bash | ||
sudo apt install libpq-dev | ||
``` | ||
**Available interactions** (See [Makefile](./Makefile)) | ||
|
||
```bash | ||
cargo install diesel_cli --features=postgres --no-default-features | ||
``` | ||
1. Create a migration | ||
|
||
### Create a migration | ||
```bash | ||
mkdir -p migrations # | ||
diesel migration generate my_migration | ||
``` | ||
|
||
```bash | ||
mkdir migrations | ||
``` | ||
Program after that `up.sql` and `down.sql` scripts. | ||
|
||
```bash | ||
diesel migration generate my_migration | ||
``` | ||
2. Run a Docker container with PostgreSQL | ||
|
||
Program after that `up.sql` and `down.sql` scripts. | ||
- See in [Makefile](https://github.com/ThalosES/vinted-rs/blob/main/Makefile) | ||
|
||
### Run a Docker container with PostgreSQL | ||
```bash | ||
make db | ||
``` | ||
|
||
- See in [Makefile](https://github.com/TuTarea/vinted-rs/blob/main/Makefile) | ||
3. Run migrations | ||
|
||
```bash | ||
make db | ||
``` | ||
```bash | ||
make diesel | ||
``` | ||
|
||
### Run migrations | ||
4. Stop DB | ||
|
||
```bash | ||
make diesel | ||
``` | ||
```bash | ||
make stop | ||
``` | ||
|
||
#### Testing set-up | ||
|
||
### Stop DB | ||
> This step requires completing the [DB setup](#database-set-up) | ||
|
||
```bash | ||
make stop | ||
cargo test | ||
``` | ||
|
||
## Running Tests | ||
### Redis | ||
|
||
⚠️**Very important:** Before running tests is important to do the [DB setup](#db-setup) | ||
This feature allows recovered results to be cached using a Redis instance. <code><img width="4%" src="https://raw.githubusercontent.com/yurijserrano/Github-Profile-Readme-Logos/refs/heads/master/databases/redis.svg"></code> | ||
|
||
Then run the tests | ||
A development instance can be created using: | ||
|
||
```bash | ||
cargo test | ||
``` | ||
make cache | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.venv | ||
result/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
[package] | ||
name = "filter_example" | ||
version = "0.1.0" | ||
version = "0.10.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
vinted-rs = { path = "../../", features = ["advanced_filters"]} | ||
bb8-postgres = {version = "0.8", features = ["with-serde_json-1" , "with-uuid-1" , "with-chrono-0_4"]} | ||
vinted-rs = { path = "../../", features = ["advanced_filters"] } | ||
bb8-postgres = { version = "0.8", features = [ | ||
"with-serde_json-1", | ||
"with-uuid-1", | ||
"with-chrono-0_4", | ||
] } | ||
tokio = { version = "1", features = ["full"] } | ||
dotenvy = { version = "0.15.7" } | ||
lazy_static = { version = "1.4.0" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Advanced filter example project | ||
|
||
## Rust set-up | ||
|
||
Refer to the [main README *Install* section](../../README.md#installation) and its subsections | ||
|
||
## Python set-up | ||
|
||
1. Create a Virtual Environment | ||
|
||
```bash | ||
python -m venv .venv | ||
``` | ||
|
||
2. Install the requirements | ||
|
||
```bash | ||
source .venv/bin/activate #linux | ||
pip install -r requirements.txt | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.