Skip to content

Commit

Permalink
Merge pull request #23 from rafaelpezzuto/refact-and-add-tsv
Browse files Browse the repository at this point in the history
Refatora código e adiciona renderizador TSV
  • Loading branch information
rafaelpezzuto authored Jan 25, 2022
2 parents 56f5dec + 23d67d4 commit 0c610d6
Show file tree
Hide file tree
Showing 22 changed files with 957 additions and 574 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ build
dist
*.egg-info
Pipfile
*.pyc
launch.json
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ _Run_
docker run -d \
-p 6543:6543 \
--name scielo-sushi-api \
--env MARIADB_STRING_CONNECTION="mysql://user:pass@localhost:port/database" \
--env STR_CONNECTION="mysql://user:pass@localhost:port/database" \
--env APPLICATION_URL="http://127.0.0.1:6543" \
scieloorg/scielo-sushi-api \
pserve /app/config.ini
```

_Environment variables_
| Variable | Description |
|-------- | ----------- |
| `APPLICATION_URL` | Application address |
| `STR_CONNECTION` | Database string connection |


## Routes

URL | Description |
Expand All @@ -32,9 +39,9 @@ URL | Description |


### Parameters (for `tr` reports only)
| Name | Description |
| Name | Description |
|------|-------------|
| `begin_date` | Usage start date in the form o YYYY-MM or YYYY-MM-DD. |
| `end_date` | Usage end date in the form o YYYY-MM or YYYY-MM-DD. |
| `granularity` | Optional Report Attribute. Include this parameter to allow usage to be retrieved with a granularity of 'month' (default if omitted) or 'totals'. |
| `issn` | ISSN of a Journal. |
| `issn` | ISSN of a Journal. |
6 changes: 4 additions & 2 deletions api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
from os import environ
from .models import DBSession, Base
from api.models.sql_automap import DBSession, Base


def main(global_config, **settings):
sqlalchemy_url_value = environ.get('MARIADB_STRING_CONNECTION', 'mysql://root:[email protected]:3306/matomo')
sqlalchemy_url_value = environ.get('STR_CONNECTION', 'mysql://root:[email protected]:3306/matomo')
settings.update({'sqlalchemy.url': sqlalchemy_url_value})

application_url_value = environ.get('APPLICATION_URL', 'http://127.0.0.1:6543')
Expand All @@ -17,6 +17,8 @@ def main(global_config, **settings):
DBSession.configure(bind=engine)
Base.metadata.bind = engine

config.add_renderer('tsv', 'api.renderers.TSVRenderer')

config.add_route('home', '/')
config.add_route('status', '/status')
config.add_route('members', '/members')
Expand Down
Loading

0 comments on commit 0c610d6

Please sign in to comment.