Install Docker
. Instructions can be found here:
Create virtual env:
$ python3 -m venv env
Install requirements.txt
:
(env) $ pip3 install -r requirements.txt
Build Docker
containers from images:
$ sudo docker-compose build
Start Docker
containers:
$ sudo docker-compose up
Build Docker
containers from images:
$ sudo docker-compose build
Start Docker
containers:
$ sudo docker-compose up
Get list of all Docker
images:
$ docker images
Delete Docker
image:
$ docker rmi <image_id>
Get list of all Docker
containers:
$ docker ps -a
Delete Docker
container:
$ docker rm <container_id>
Delete all stopped Docker
containers:
$ docker container prune
Delete all unused Docker
images:
$ docker image prune -a
Delete all dangling Docker
images:
$ docker image prune
Fill database with data:
$ make fill_crypto_db
This action requires setting
CRYPTOCURRENCY_ACCESS_KEY
insettings.py
file
Process parsed data:
$ make process_parsed
The list of other available commands is available in
Makefile
GraphQL
module can be accessed by going to /graphql
link.
For example, to get all shawarmas
, we can use this query:
query get_shawarmas {
allShawarmas{
edges {
node {
id
name
weight
price
ingredients {
id
name
}
}
}
}
}
The expected result is:
{
"data": {
"allShawarmas": {
"edges": [
{
"node": {
"id": "U2hhd2FybWFOb2RlOjE=",
"name": "Шаурма восточная с курицей",
"weight": 335,
"price": 93,
"ingredients": [
{
"id": "1",
"name": "огурец соленый"
},
{
"id": "2",
"name": "лаваш арабский"
},
{
"id": "3",
"name": "мясо куриное"
},
{
"id": "4",
"name": "чесночный соус"
},
{
"id": "5",
"name": "зелень"
}
]
}
},
...
We can filter our result set. For example, to get all shawarmas
, whose name contain a <string>
, we can use this query:
query get_shawarmas {
allShawarmas(name_Icontains: "<string>") {
edges {
node {
id
name
weight
price
ingredients {
id
name
}
}
}
}
}
To get specific shawarma
, we can use this query:
query get_shawarmas {
shawarma(id: "U2hhd2FybWFOb2RlOjE="){
id
name
weight
price
}
}
Here is the list of all available lookup expressions and examples:
(name: "курица") # Exact search
(name_Icontains: "курица") # Contains
(weight_Lt: 400) # Less than
(price_Gt: 100) # Greater than
Create redis user (legacy):
set user:1 User
set password:1 password
In weather_app
directory run (legacy):
$ celery -A weather_app worker --loglevel=info
Install PostgreSQL (legacy):
$ sudo apt-get install postgresql
$ pip install psycopg2-binary
Setup and configure database (legacy):
$ sudo -u postgres psql
Postgres=# CREATE DATABASE weather_db;
Postgres=# CREATE USER admin WITH PASSWORD '1111';
Postgres=# ALTER ROLE admin SET client_encoding TO 'utf8';
Postgres=# ALTER ROLE admin SET default_transaction_isolation TO 'read committed';
Postgres=# ALTER ROLE admin SET timezone TO 'UTC';
Postgres=# GRANT ALL PRIVILEGES ON DATABASE weather_db TO admin;
Exit SQL console:
Postgres=# \q