Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.db
tests/yaml/**/*.yml
tests/yaml/**/*.yaml
tests/yaml/**/*.png

# User-specific stuff
.idea/**/workspace.xml
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Changelog

## [Unreleased](https://github.com/tracktor-one/tracktor/tree/HEAD)

[Full Changelog](https://github.com/tracktor-one/tracktor/compare/7c0c9a1038fb019690a6f9c748d6bbcfcc88dc54...HEAD)

**Closed issues:**

- Add Models of items [\#11](https://github.com/tracktor-one/tracktor/issues/11)
- Add the possibility to schedule a playlist for release in the future [\#7](https://github.com/tracktor-one/tracktor/issues/7)
- Persistence [\#5](https://github.com/tracktor-one/tracktor/issues/5)
- Handle playlist images [\#4](https://github.com/tracktor-one/tracktor/issues/4)
- Authentication [\#3](https://github.com/tracktor-one/tracktor/issues/3)
- Configure routing [\#2](https://github.com/tracktor-one/tracktor/issues/2)
- Creating basic structure as structs [\#1](https://github.com/tracktor-one/tracktor/issues/1)

**Merged pull requests:**

- Add remaining models with sql migrations [\#22](https://github.com/tracktor-one/tracktor/pull/22) ([saskiagrun](https://github.com/saskiagrun))
- Put some information into the README [\#21](https://github.com/tracktor-one/tracktor/pull/21) ([saskiagrun](https://github.com/saskiagrun))
- Python black formatting [\#20](https://github.com/tracktor-one/tracktor/pull/20) ([saskiagrun](https://github.com/saskiagrun))
- Use SQLModel instead of manually written sqlalchemy table objects [\#19](https://github.com/tracktor-one/tracktor/pull/19) ([saskiagrun](https://github.com/saskiagrun))
- Add lint workflows and Docker [\#16](https://github.com/tracktor-one/tracktor/pull/16) ([h4llow3En](https://github.com/h4llow3En))
- Add authentication and User management [\#15](https://github.com/tracktor-one/tracktor/pull/15) ([h4llow3En](https://github.com/h4llow3En))
- refactoring to fastapi [\#14](https://github.com/tracktor-one/tracktor/pull/14) ([h4llow3En](https://github.com/h4llow3En))
- Add custom error [\#13](https://github.com/tracktor-one/tracktor/pull/13) ([h4llow3En](https://github.com/h4llow3En))
- Add lint and format workflow [\#9](https://github.com/tracktor-one/tracktor/pull/9) ([h4llow3En](https://github.com/h4llow3En))
- Clean up to start from scratch [\#8](https://github.com/tracktor-one/tracktor/pull/8) ([h4llow3En](https://github.com/h4llow3En))
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM python:3.9-buster

RUN set -x ; addgroup --gid 1000 tracktor ; adduser --uid 1000 --ingroup tracktor tracktor && exit 0 ; exit 1
#hadolint ignore=DL3008
RUN set -x ; addgroup --gid 1000 tracktor ; adduser --uid 1000 --ingroup tracktor tracktor && exit 0 ; exit 1 \
&& apt-get update -qq && apt-get install -y --no-install-recommends g++ libmagic-dev libgraphicsmagick++1-dev libyaml-dev libboost-python-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
USER tracktor
COPY --chown=tracktor:tracktor requirements.txt /
RUN pip install --no-cache-dir -r requirements.txt
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ To reduce redundant information an API is the easiest way to get them.
### For development

1. Clone this Repository
2. Create an venv or simply run `pip install -r requirements.txt`
3. Run `uvicorn tracktor:main --reload`
2. Install GraphicsMagic (e.g. `apt-get install g++ libgraphicsmagick++1-dev libboost-python-dev`)
3. Create a venv or simply run `pip install -r requirements.txt`
4. Run `alembic upgrade head` to apply migrations or create sqlite database
5. Run `uvicorn tracktor:app --reload`

## API Endpoints and Models

Expand Down
31 changes: 10 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,19 @@ services:
ports:
- 80:80
environment:
# FOR SQLITE
# - DATABASE_TYPE=sqlite
# - DATABASE_PATH=/
- DATABASE_TYPE=sqlite
- DATABASE_PATH=/opt/tracktor/data/tracktor.db

- DATABASE_TYPE=mysql
# - DATABASE_TYPE=postgresql
- DATABASE_USER=tracktor
- DATABASE_PASS=tracktor
- DATABASE_HOST=database
- DATABASE_NAME=tracktor
# FOR POSTGRES
# - DATABASE_TYPE=postgresql
# - DATABASE_USER=tracktor
# - DATABASE_PASS=tracktor
# - DATABASE_HOST=database
# - DATABASE_NAME=tracktor
volumes:
- ./data:/opt/tracktor/data

database:
image: mariadb:10
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=1
- MYSQL_USER=tracktor
- MYSQL_PASSWORD=tracktor
- MYSQL_DATABASE=tracktor
networks:
- backend

# EXAMPLE FOR POSTGRES
# database:
# container_name: codimd_db
# image: postgres:14.0-alpine
# environment:
# - POSTGRES_USER=tracktor
Expand Down
2 changes: 1 addition & 1 deletion migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tracktor.config import config as tc

# This import is needed to generate metadata for SQLModels
from tracktor.models import User, Category, Playlist, PlaylistItemLink, Item
from tracktor.models import *

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand Down
88 changes: 0 additions & 88 deletions migrations/versions/979da9b7aff0_add_playlist_and_item_models.py

This file was deleted.

65 changes: 0 additions & 65 deletions migrations/versions/a2ced875a244_initial_model_generation.py

This file was deleted.

85 changes: 85 additions & 0 deletions migrations/versions/d5a13c49db61_initial_model_creation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""initial model creation

Revision ID: d5a13c49db61
Revises:
Create Date: 2022-02-22 19:16:32.218339

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel


# revision identifiers, used by Alembic.
revision = 'd5a13c49db61'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('category',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('id', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('image',
sa.Column('entity_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('id', sa.Integer(), nullable=True),
sa.Column('image', sa.LargeBinary(), nullable=False),
sa.Column('file_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('mime_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('file_name'),
sa.UniqueConstraint('image')
)
op.create_table('item',
sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('artist', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('id', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('password', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('admin', sa.Boolean(), nullable=False),
sa.Column('entity_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('last_login', sa.DateTime(), nullable=True),
sa.Column('id', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('playlist',
sa.Column('entity_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('spotify', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('amazon', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('apple_music', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('release_date', sa.DateTime(), nullable=True),
sa.Column('id', sa.Integer(), nullable=True),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.Column('image_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['category_id'], ['category.id'], ),
sa.ForeignKeyConstraint(['image_id'], ['image.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('playlistitemlink',
sa.Column('playlist_id', sa.Integer(), nullable=True),
sa.Column('item_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['item_id'], ['item.id'], ),
sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], ),
sa.PrimaryKeyConstraint('playlist_id', 'item_id')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('playlistitemlink')
op.drop_table('playlist')
op.drop_table('user')
op.drop_table('item')
op.drop_table('image')
op.drop_table('category')
# ### end Alembic commands ###
21 changes: 11 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
fastapi~=0.70.0
packaging >= 20.9
SQLAlchemy~=1.4.21
sqlmodel~=0.0.4
asyncpg~=0.24.0
asyncmy~=0.2.3
PyMySQL~=1.0.2
fastapi~=0.74.1
packaging>=21.3
SQLAlchemy~=1.4.31
sqlmodel~=0.0.6
asyncpg~=0.25.0
aiosqlite~=0.17.0
alembic~=1.7.4
Werkzeug~=2.0.1
psycopg2-binary~=2.9.3
alembic~=1.7.6
Werkzeug~=2.0.3
python-multipart~=0.0.5
python-jose[cryptography]
PyYAML~=6.0
python-magic==0.4.25

uvicorn
uvicorn>=0.17.5
1 change: 1 addition & 0 deletions tests/test_image.py

Large diffs are not rendered by default.

Loading