Skip to content

Commit

Permalink
version-0.2 (#5)
Browse files Browse the repository at this point in the history
### DONE (v0.2)
- [x] Fix database session with get_db or get_session
- [x] Start Integration tests
- [x] Docs (mkdocs + mkdocs-material[to beautify] + mkdocstrings[to transform docstrings into docs])
- [x] mkdocs on gh pages and/or readthedocs
- [x] Taskipy
- [x] Re-enable Coordinates on database and api's (only cep_aberto available)

#### See [README.md](https://codeberg.org/Krisque/jacobson/src/branch/main/README.md) to full roadmap

### BREAKING CHANGE

- Now postgres is needed because of uuid pk.
- Remake migrations.

#### See [CHANGELOG.md](https://codeberg.org/Krisque/jacobson/src/branch/main/CHANGELOG.md) to look at every change

Reviewed-on: https://codeberg.org/Krisque/jacobson/pulls/5
Co-authored-by: Krisque <[email protected]>
Co-committed-by: Krisque <[email protected]>
  • Loading branch information
chrisemke authored and Krisque committed Aug 1, 2024
1 parent 48c72f1 commit 2e89f8e
Show file tree
Hide file tree
Showing 145 changed files with 48,540 additions and 2,766 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
root = true

[*]
indent_style = space
indent_size = 4
indent_style = tab
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{py,pyi}]
max_line_length = 80

[*.{yml,yaml}]
indent_style = space
191 changes: 99 additions & 92 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,93 +1,100 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-vcs-permalinks
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- id: check-added-large-files
- id: check-toml
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: insert-license
name: Add license for all python files
files: \.py$|\.pyi$
args:
[
--comment-style,
'"""||"""',
--license-filepath,
license-templates/LICENSE.txt,
--fuzzy-match-generates-todo,
--use-current-year,
--no-space,
]
- id: insert-license
name: Add license for all Markdown files
files: \.md$
args:
[
--comment-style,
"<!--||-->",
--license-filepath,
license-templates/LICENSE.txt,
--fuzzy-match-generates-todo,
--no-space,
]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
hooks:
- id: ruff
name: Run Ruff Linter & Formater
args: [--fix, --exit-non-zero-on-fix]
exclude: |
(?x)^(
^build/|
^docker/|
^tests/
)
- id: ruff-format
name: Run Ruff Formater
exclude: |
(?x)(
^build/|
^docker/|
^tests/
)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
name: Run Mypy (Static type checker)
exclude: |
(?x)(
^build/|
^docker/|
^tests/
)
additional_dependencies:
[strawberry-graphql, pydantic, pydantic-settings, sqlmodel]
- repo: https://github.com/python-poetry/poetry
rev: "1.8.0"
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: [-o, requirements.txt]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.27.0
hooks:
- id: commitizen
- id: commitizen-branch
stages:
- post-commit
- push
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-vcs-permalinks
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- id: check-added-large-files
args: ["--maxkb=1000"]
- id: check-toml
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: insert-license
name: Add license for all python files
files: \.py$|\.pyi$
args:
[
--comment-style,
'"""||"""',
--license-filepath,
license-templates/LICENSE.txt,
--fuzzy-match-generates-todo,
--use-current-year,
--no-space,
]
- id: insert-license
name: Add license for all Markdown files
files: \.md$
args:
[
--comment-style,
"<!--||-->",
--license-filepath,
license-templates/LICENSE.txt,
--fuzzy-match-generates-todo,
--no-space,
]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
hooks:
- id: ruff-format
name: Run Ruff Formater
exclude: |
(?x)(
^build/|
^docker/
)
- id: ruff
name: Run Ruff Linter
args: [--fix, --exit-non-zero-on-fix]
exclude: |
(?x)^(
^build/|
^docker/|
^tests/
)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
hooks:
- id: mypy
name: Run Mypy (Static type checker)
exclude: |
(?x)(
^build/|
^docker/|
^tests/
)
additional_dependencies:
[
"strawberry-graphql[fastapi]",
pydantic,
pydantic-settings,
sqlmodel,
]
- repo: https://github.com/python-poetry/poetry
rev: "1.8.0"
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: [-o, requirements.txt]
- id: poetry-export
args: [-o, requirements_dev.txt, --with=docs]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.28.0
hooks:
- id: commitizen
- id: commitizen-branch
stages:
- post-commit
- push
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

## Unreleased
## 0.1 (2024-05-28)

### BREAKING CHANGE

Expand Down Expand Up @@ -49,3 +49,22 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
- **graphql-query**: add pydantic and strawberry types to query
- start edgedb support
- create docker folders and minor fixes

## 0.2 (2024-07-31)

### BREAKING CHANGE

- Now postgres is needed because of uuid pk. Remake migrations

### Fix

- **all_address**: add joins on filters that depend on other tables
- **background-insert**: fix insert on query to run after return
- **plugins-async-error**: create async client to run requests async

### Refactor

- **remake-database**: move from mariadb to postgres, re-enable coordinates and move to uuid
- **mkdocs-dev-mode**: if dev mode is on, mkdocs is enabled on / of fastapi
- **dev-mode**: add dev flag on .env to enable some features like db logs on shell and graphql ide
- **db-session**: add graphql context_getter to send the database session to queries and mutations on demand
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,42 @@ call to tell the api to update some register from plugins that are configured

# ROADMAP:

## TODO (Needed for v0.1)
## DONE (v0.1)
- [x] git hooks (pre-commit)
- [x] ORM (SqlModel)
- [x] Api's support services (cepaberto, viacep...)
- [x] Unit tests (pytest)
- [x] Migrations and data seed (Alembic)

## TODO (Needed for v0.2)
- [ ] Integration tests
- [ ] Better structure for services (plugin-like)
## DONE (v0.2)
- [x] Fix database session with get_db or get_session
- [x] Start Integration tests
- [x] Docs (mkdocs + mkdocs-material[to beautify] + mkdocstrings[to transform docstrings into docs])
- [x] mkdocs on gh pages and/or readthedocs
- [x] Taskipy
- [x] Re-enable Coordinates on database and api's (only cep_aberto available)

## TODO (Needed for v0.3)
- [ ] Add log support (loguru? or OpenTelemetry?)
- [ ] Custom exceptions
- [ ] Add log support (loguru)
- [ ] Docs (mkdocs + mkdocs-material[to beautify] + mkdocstrings[to transform docstrings into docs])
- [ ] Resolve code issues (TODO's on docstrings)
- [ ] Auth (pyjwt+pwdlib)
- [ ] More test (unit and integration)

## TODO (Needed until v1.0)
- [ ] Auth
- [ ] mkdocs on gh pages
- [ ] Populate the database with zip codes and cities
- [ ] Automate migrations tests?
- [ ] separate tests into groups to be run selectively
- [ ] git hooks to run fast and slow tests
- [ ] Resolve all code issues (TODO's on docstrings)
- [ ] CI and CI tests
- [ ] freeze versions on docker and pyproject
- [ ] Better structure for services (plugin-like)
- [ ] Send 'total' information on api requests for pagination

### TODO (nice to have)
- [ ] add option to data seed all cities (or chosen list)
- [ ] add option to seed all cities (or chosen list)
- [ ] add option to seed all zip codes (or chosen list)
- [ ] add graphql schema generator on git hooks
- [ ] move from docker-compose to a podman pod
- [ ] study mypyc viability
- [ ] jacobson logo
Expand All @@ -65,6 +79,8 @@ The idea is to just run this command and podman will run the entire dev environm

obs: before this command you need to create the .env (see sample.env for example)

to run podman as expected, you will need the packages "podman", "podman-compose" and "aardvark-dns"

```bash
podman compose up -d --build
```
Expand Down
64 changes: 33 additions & 31 deletions api/address/graphql_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,52 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

from strawberry import auto
from strawberry import auto, input
from strawberry.experimental.pydantic import input as pydantic_input

from database.models.brazil import Address, AddressBase, City, State
from database.models.brazil import (
Address,
AddressBase,
CityBase,
StateBase,
)


@pydantic_input(model=State)
@pydantic_input(StateBase)
class StateInput:
acronym: auto
# Needed until strawberry support auto | None type
# https://github.com/strawberry-graphql/strawberry/issues/3435
name: str | None = None
acronym: auto
name: auto


@pydantic_input(model=City)
@pydantic_input(CityBase)
class CityInput:
ibge: auto
# Needed until strawberry support auto | None type
# https://github.com/strawberry-graphql/strawberry/issues/3435
name: str | None = None
ddd: auto
ibge: auto
name: auto
ddd: auto


# @input
# class CoordinatesInput:
# latitude: float
# longitude: float
# altitude: float | None = None
@input
class CoordinatesInput:
latitude: float
longitude: float
altitude: float | None = None


@pydantic_input(model=AddressBase)
@pydantic_input(AddressBase)
class AddressFilterInput:
zipcode: auto
city: CityInput | None = None
state: StateInput | None = None
neighborhood: auto
complement: auto
# coordinates: CoordinatesInput | None = None
zipcode: auto
city: CityInput | None = None
state: StateInput | None = None
neighborhood: auto
complement: auto
coordinates: CoordinatesInput | None = None


@pydantic_input(model=Address)
@pydantic_input(Address)
class AddressInsertInput:
zipcode: auto
state: StateInput
city: CityInput
neighborhood: auto
complement: auto
zipcode: auto
state: StateInput
city: CityInput
neighborhood: auto
complement: auto
coordinates: CoordinatesInput | None = None
Loading

0 comments on commit 2e89f8e

Please sign in to comment.