Skip to content

Commit

Permalink
BrittleFoot/week-3
Browse files Browse the repository at this point in the history
Week 3
  • Loading branch information
BrittleFoot authored Mar 11, 2024
2 parents c61e607 + 0d45c4d commit 9f349c4
Show file tree
Hide file tree
Showing 235 changed files with 9,501 additions and 647 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.vscode
aa_service_template
.env
**/.*_cache
**/.*_cache
.DS_Store
182 changes: 182 additions & 0 deletions analytics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

# End of https://www.toptal.com/developers/gitignore/api/python


.vscode/
.piterpy/
junit
src/static/
1 change: 1 addition & 0 deletions analytics/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
21 changes: 21 additions & 0 deletions analytics/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.12-slim

RUN apt update && \
apt install --no-install-recommends -y \
build-essential git locales-all wait-for-it

RUN pip install --no-cache-dir --upgrade pip uwsgi

ADD requirements.txt /srv

RUN pip install --no-cache-dir -r /srv/requirements.txt

ADD src /srv
RUN rm -f /srv/.env
WORKDIR /srv


RUN ./manage.py collectstatic --noinput

CMD ./manage.py migrate && \
uwsgi --master --http :8000 --module app.wsgi
23 changes: 23 additions & 0 deletions analytics/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
deps:
pip-compile requirements.in
pip-compile dev-requirements.in
pip-sync requirements.txt dev-requirements.txt

lint:
ruff src $(ARGS)

fix:
ruff src --fix

test:
pytest src $(ARGS)

start:
docker-compose up -d
cd src && ./manage.py runserver 9200

consumer:
cd src && ./manage.py consumer

# image:
# docker build -t test .
1 change: 1 addition & 0 deletions analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# django_template
8 changes: 8 additions & 0 deletions analytics/dev-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ruff

pytest
pytest-cov
pytest-django
mixer

ipython
69 changes: 69 additions & 0 deletions analytics/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile dev-requirements.in
#
asttokens==2.4.1
# via stack-data
coverage[toml]==7.4.1
# via
# coverage
# pytest-cov
decorator==5.1.1
# via ipython
executing==2.0.1
# via stack-data
faker==12.0.1
# via mixer
iniconfig==2.0.0
# via pytest
ipython==8.21.0
# via -r dev-requirements.in
jedi==0.19.1
# via ipython
matplotlib-inline==0.1.6
# via ipython
mixer==7.2.2
# via -r dev-requirements.in
packaging==23.2
# via pytest
parso==0.8.3
# via jedi
pexpect==4.9.0
# via ipython
pluggy==1.4.0
# via pytest
prompt-toolkit==3.0.43
# via ipython
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.2
# via stack-data
pygments==2.17.2
# via ipython
pytest==8.0.0
# via
# -r dev-requirements.in
# pytest-cov
# pytest-django
pytest-cov==4.1.0
# via -r dev-requirements.in
pytest-django==4.8.0
# via -r dev-requirements.in
python-dateutil==2.8.2
# via faker
ruff==0.2.1
# via -r dev-requirements.in
six==1.16.0
# via
# asttokens
# python-dateutil
stack-data==0.6.3
# via ipython
traitlets==5.14.1
# via
# ipython
# matplotlib-inline
wcwidth==0.2.13
# via prompt-toolkit
23 changes: 23 additions & 0 deletions analytics/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3'


services:
postgres:
image: postgres:16.1
ports:
- 5444:5432
environment:
- POSTGRES_HOST_AUTH_METHOD=trust

# Test local run in docker
# build app image with `make image` (also commented) beforehand

# backend:
# image: test
# command: wait-for-it postgres:5432 -- /bin/sh -c "./manage.py migrate && uwsgi --master --http :8000 --module app.wsgi"
# ports:
# - 8000:8000
# environment:
# - DATABASE_URL=postgres://postgres@postgres/postgres
# links:
# - postgres
8 changes: 8 additions & 0 deletions analytics/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tool.ruff]
lint.select = ["E4", "E7", "E9", "F", "B", "W", "Q", "I"]
line-length = 90


[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "app.settings"
pythonpath = "src"
16 changes: 16 additions & 0 deletions analytics/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Django<=6
djangorestframework
django-environ
django-behaviors
django-cors-headers
django-oauth-toolkit
djangorestframework-camel-case
whitenoise
requests
pydantic
../popug_schema

psycopg2-binary
uritemplate
pyyaml
confluent-kafka
Loading

0 comments on commit 9f349c4

Please sign in to comment.