Run pre-commit
Co-authored-by: Ezequiel Bellver <ebellver@itba.edu.ar> Co-authored-by: Juan Barmasch <jbarmasch@itba.edu.ar>
This commit is contained in:
parent
26cb63ba22
commit
958d658693
README.md
bsition
|
@ -44,7 +44,7 @@ POSTGRES_USER=root
|
|||
POSTGRES_PASSWORD=password
|
||||
```
|
||||
|
||||
En un ambiente de testeo (como es el caso) puede simplemente copiar el archivo pero, si se corriese en producción, se deberían cambiar las contraseñas.
|
||||
En un ambiente de testeo (como es el caso) puede simplemente copiar el archivo pero, si se corriese en producción, se deberían cambiar las contraseñas.
|
||||
|
||||
Debe dejar los URLs de las bases de datos como se indicaron pues así se las configuró con docker.
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ from dotenv import load_dotenv
|
|||
from fastapi import FastAPI
|
||||
|
||||
from bsition.api.components.document import documents_routes
|
||||
from bsition.api.components.user import users_routes
|
||||
from bsition.api.components.table import tables_routes
|
||||
from bsition.api.components.user import users_routes
|
||||
from bsition.api.routes.auth import auth_routes
|
||||
|
||||
app = FastAPI()
|
||||
|
|
|
@ -4,9 +4,8 @@ from fastapi import APIRouter, Response, status
|
|||
from pydantic import BaseModel
|
||||
from pydantic.types import Optional
|
||||
|
||||
from bsition.backend import mongo
|
||||
from bsition.backend import elastic
|
||||
from bsition.api.middleware.verify_token import VerifyTokenRoute
|
||||
from bsition.backend import elastic, mongo
|
||||
|
||||
documents_routes = APIRouter(route_class=VerifyTokenRoute)
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ from fastapi import APIRouter, Response, status
|
|||
from pydantic import BaseModel
|
||||
from pydantic.utils import Optional
|
||||
|
||||
from bsition.backend import postgres
|
||||
from bsition.api.middleware.verify_token import VerifyTokenRoute
|
||||
from bsition.backend import postgres
|
||||
|
||||
tables_routes = APIRouter(route_class=VerifyTokenRoute)
|
||||
|
||||
|
@ -77,4 +77,3 @@ def add_filter(aux: Filter, name: str):
|
|||
@tables_routes.get("/tables/{name}/filter")
|
||||
def filter(name: str):
|
||||
return postgres.filter(name)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from fastapi import APIRouter, Response, status
|
||||
from pydantic import BaseModel
|
||||
|
||||
from bsition.backend import postgres
|
||||
from bsition.api.middleware.verify_token import VerifyTokenRoute
|
||||
from bsition.backend import postgres
|
||||
|
||||
users_routes = APIRouter()
|
||||
|
||||
|
@ -35,4 +35,3 @@ def get_by_id(id: str):
|
|||
def edit_user(aux: User, id: str, response: Response):
|
||||
postgres.edit_user(id, aux.username, aux.password)
|
||||
response.status_code = status.HTTP_202_ACCEPTED
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from dotenv import load_dotenv
|
||||
|
||||
from bsition.backend.postgres import *
|
||||
from bsition.backend.elastic import *
|
||||
from bsition.backend.postgres import *
|
||||
|
||||
|
||||
def configure():
|
||||
|
|
|
@ -54,6 +54,8 @@ def search(index, query):
|
|||
print(resp["hits"])
|
||||
print(hit["_source"])
|
||||
print("%(name)s: %(data)s" % hit["_source"])
|
||||
hits.append(str(hit["highlight"]) + " ---- " + "%(name)s: %(data)s" % hit["_source"])
|
||||
hits.append(
|
||||
str(hit["highlight"]) + " ---- " + "%(name)s: %(data)s" % hit["_source"]
|
||||
)
|
||||
|
||||
return hits
|
||||
|
|
|
@ -14,7 +14,18 @@ def get_database():
|
|||
def get_documents():
|
||||
dbname = get_database()
|
||||
docs_coll = dbname["docs"]
|
||||
pipeline = [{'$project': {"id": {'$toString': "$_id"}, "_id": 0, "data": 1, "name": 1, "access": 1, "owner": 1}}]
|
||||
pipeline = [
|
||||
{
|
||||
"$project": {
|
||||
"id": {"$toString": "$_id"},
|
||||
"_id": 0,
|
||||
"data": 1,
|
||||
"name": 1,
|
||||
"access": 1,
|
||||
"owner": 1,
|
||||
}
|
||||
}
|
||||
]
|
||||
return list(docs_coll.aggregate(pipeline))
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import inspect
|
||||
from os import getenv
|
||||
|
||||
from psycopg2 import sql, connect
|
||||
from psycopg2 import connect, sql
|
||||
|
||||
|
||||
def get_connection():
|
||||
|
@ -55,7 +55,9 @@ def edit_columns(name, columns, data, id):
|
|||
for column in columns:
|
||||
cur.execute(
|
||||
sql.SQL("UPDATE {table} SET {col} = %s WHERE row_number = {id}").format(
|
||||
table=sql.Identifier(name), col=sql.Identifier(column), id=sql.Literal(id)
|
||||
table=sql.Identifier(name),
|
||||
col=sql.Identifier(column),
|
||||
id=sql.Literal(id),
|
||||
),
|
||||
[data[i]],
|
||||
)
|
||||
|
@ -255,9 +257,7 @@ def add_user(username, password):
|
|||
def get_users():
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"SELECT * FROM users"
|
||||
)
|
||||
cur.execute("SELECT * FROM users")
|
||||
return list(cur.fetchall())
|
||||
|
||||
|
||||
|
@ -296,8 +296,9 @@ def edit_user(id, username, password):
|
|||
print(id)
|
||||
cur.execute(
|
||||
sql.SQL("UPDATE users SET {col} = {value} WHERE id = {id}").format(
|
||||
col=sql.Identifier(column), value=sql.Literal(data[i]), id=sql.Literal(id)
|
||||
col=sql.Identifier(column),
|
||||
value=sql.Literal(data[i]),
|
||||
id=sql.Literal(id),
|
||||
),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
|
|
Loading…
Reference in New Issue