Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Gabriel Weisse
/
presupuestov1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
pr0nstar
2026-04-14 12:46:53 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5e81514f9f61b13537b03224620f97a858c3d971
5e81514f
1 parent
03803f46
X
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
0 deletions
routers/_decorators.py
routers/classifier.py
routers/classifier_income.py
routers/daily.py
routers/entity.py
routers/_decorators.py
0 → 100644
View file @
5e81514
from
functools
import
wraps
from
fastapi
import
HTTPException
from
sqlalchemy.exc
import
NoResultFound
def
not_found
(
fn
):
@wraps
(
fn
)
def
wrapper
(
*
args
,
**
kwargs
):
try
:
value
=
fn
(
*
args
,
**
kwargs
)
except
NoResultFound
as
exc
:
raise
HTTPException
(
status_code
=
404
,
detail
=
'Not found'
)
from
exc
if
value
is
None
:
raise
HTTPException
(
status_code
=
404
,
detail
=
'Not found'
)
if
isinstance
(
value
,
(
list
,
dict
))
and
not
value
:
raise
HTTPException
(
status_code
=
404
,
detail
=
'Not found'
)
return
value
return
wrapper
routers/classifier.py
View file @
5e81514
...
...
@@ -7,6 +7,7 @@ from sqlalchemy.orm import Session
from
sqlalchemy
import
and_
,
or_
,
select
from
presupuestov1
import
model
,
schema
,
constant
,
schemas
,
models
,
search
from
presupuestov1.routers._decorators
import
not_found
router_objeto
=
APIRouter
(
...
...
@@ -31,21 +32,25 @@ router_finfun = APIRouter(
###############################################################################
@router_objeto.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasObjetos
])
@not_found
def
fetch_object_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
)):
return
_fetch_classifier
(
'objeto'
,
db
)
@router_acteco.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasActeco
])
@not_found
def
fetch_object_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
)):
return
_fetch_classifier
(
'acteco'
,
db
)
@router_finfun.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasFinfun
])
@not_found
def
fetch_object_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
)):
return
_fetch_classifier
(
'finfun'
,
db
)
@router_objeto.get
(
'/{object_id}'
,
response_model
=
schemas
.
objeto
.
ClasObjetosEstados
)
@not_found
def
fetch_objeto_estado
(
object_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -65,6 +70,7 @@ def fetch_objeto_estado(
@router_objeto.get
(
'/{object_id}/entidades'
,
response_model
=
List
[
schemas
.
objeto
.
ObjetoEntidad
])
@not_found
def
fetch_objeto_entidad
(
object_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -82,6 +88,7 @@ def fetch_objeto_entidad(
@router_objeto.get
(
'/{object_id}/ubigeos'
,
response_model
=
List
[
schemas
.
objeto
.
ObjetoUbigeo
])
@not_found
def
fetch_objeto_ubigeo
(
object_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -97,6 +104,7 @@ def fetch_objeto_ubigeo(
@router_objeto.get
(
'/{object_id}/entidades/map'
,
response_model
=
List
[
schemas
.
treemap
.
TreemapObjetoSingle
])
@not_found
def
fetch_objeto_treemap
(
object_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -110,6 +118,7 @@ def fetch_objeto_treemap(
)
@router_objeto.get
(
'/{object_id}/entidades/{entidad_id}'
,
response_model
=
List
[
schemas
.
objeto
.
ObjetoEntidad
])
@not_found
def
fetch_objeto_entidad_single
(
object_id
:
str
,
entidad_id
:
int
,
...
...
@@ -125,6 +134,7 @@ def fetch_objeto_entidad_single(
@router_objeto.get
(
'/{object_id}/ubigeos/{ubigeo_id}'
,
response_model
=
List
[
schemas
.
objeto
.
ObjetoUbigeo
])
@not_found
def
fetch_objeto_ubigeo_single
(
object_id
:
str
,
ubigeo_id
:
str
,
...
...
@@ -140,6 +150,7 @@ def fetch_objeto_ubigeo_single(
@router_acteco.get
(
'/{acteco_id}'
,
response_model
=
schemas
.
acteco
.
ClasActecoEstados
)
@not_found
def
fetch_acteco_estado
(
acteco_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -159,6 +170,7 @@ def fetch_acteco_estado(
@router_acteco.get
(
'/{acteco_id}/entidades'
,
response_model
=
List
[
schemas
.
acteco
.
ActecoEntidad
])
@not_found
def
fetch_acteco_entidad
(
acteco_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -176,6 +188,7 @@ def fetch_acteco_entidad(
@router_acteco.get
(
'/{acteco_id}/ubigeos'
,
response_model
=
List
[
schemas
.
acteco
.
ActecoUbigeo
])
@not_found
def
fetch_acteco_ubigeo
(
acteco_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -191,6 +204,7 @@ def fetch_acteco_ubigeo(
@router_acteco.get
(
'/{acteco_id}/entidades/map'
,
response_model
=
List
[
schemas
.
treemap
.
TreemapActecoSingle
])
@not_found
def
fetch_acteco_treemap
(
acteco_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -205,6 +219,7 @@ def fetch_acteco_treemap(
@router_acteco.get
(
'/{acteco_id}/entidades/{entidad_id}'
,
response_model
=
List
[
schemas
.
acteco
.
ActecoEntidad
])
@not_found
def
fetch_acteco_entidad_single
(
acteco_id
:
str
,
entidad_id
:
int
,
...
...
@@ -220,6 +235,7 @@ def fetch_acteco_entidad_single(
@router_acteco.get
(
'/{acteco_id}/ubigeos/{ubigeo_id}'
,
response_model
=
List
[
schemas
.
acteco
.
ActecoUbigeo
])
@not_found
def
fetch_acteco_ubigeo_single
(
acteco_id
:
str
,
ubigeo_id
:
str
,
...
...
@@ -235,6 +251,7 @@ def fetch_acteco_ubigeo_single(
@router_finfun.get
(
'/{finfun_id}'
,
response_model
=
schemas
.
finfun
.
ClasFinfunEstados
)
@not_found
def
fetch_finfun_estado
(
finfun_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -254,6 +271,7 @@ def fetch_finfun_estado(
@router_finfun.get
(
'/{finfun_id}/entidades'
,
response_model
=
List
[
schemas
.
finfun
.
FinfunEntidad
])
@not_found
def
fetch_finfun_entidad
(
finfun_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -271,6 +289,7 @@ def fetch_finfun_entidad(
@router_finfun.get
(
'/{finfun_id}/ubigeos'
,
response_model
=
List
[
schemas
.
finfun
.
FinfunUbigeo
])
@not_found
def
fetch_finfun_ubigeo
(
finfun_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -286,6 +305,7 @@ def fetch_finfun_ubigeo(
@router_finfun.get
(
'/{finfun_id}/entidades/map'
,
response_model
=
List
[
schemas
.
treemap
.
TreemapFinFunSingle
])
@not_found
def
fetch_finfun_treemap
(
finfun_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -300,6 +320,7 @@ def fetch_finfun_treemap(
@router_finfun.get
(
'/{finfun_id}/entidades/{entidad_id}'
,
response_model
=
List
[
schemas
.
finfun
.
FinfunEntidad
])
@not_found
def
fetch_finfun_entidad_single
(
finfun_id
:
str
,
entidad_id
:
int
,
...
...
@@ -315,6 +336,7 @@ def fetch_finfun_entidad_single(
@router_finfun.get
(
'/{finfun_id}/ubigeos/{ubigeo_id}'
,
response_model
=
List
[
schemas
.
finfun
.
FinfunUbigeo
])
@not_found
def
fetch_finfun_ubigeo_single
(
finfun_id
:
str
,
ubigeo_id
:
str
,
...
...
routers/classifier_income.py
View file @
5e81514
...
...
@@ -5,6 +5,7 @@ from sqlalchemy.orm import Session
from
sqlalchemy
import
select
from
presupuestov1
import
model
,
schema
,
schemas
,
models
from
presupuestov1.routers._decorators
import
not_found
router_rubro
=
APIRouter
(
...
...
@@ -23,16 +24,19 @@ router_organismo = APIRouter(
###############################################################################
@router_rubro.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasRubros
])
@not_found
def
fetch_rubro_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
)):
return
_fetch_classifier
(
'rubro'
,
db
)
@router_organismo.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasOrganismos
])
@not_found
def
fetch_organismo_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
)):
return
_fetch_classifier
(
'organismo'
,
db
)
@router_rubro.get
(
'/{rubro_id}'
,
response_model
=
schemas
.
rubro
.
ClasRubrosEstados
)
@not_found
def
fetch_rubro_estado
(
rubro_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -52,6 +56,7 @@ def fetch_rubro_estado(
@router_rubro.get
(
'/{rubro_id}/entidades'
,
response_model
=
List
[
schemas
.
rubro
.
RubroEntidad
])
@not_found
def
fetch_rubro_entidad
(
rubro_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -69,6 +74,7 @@ def fetch_rubro_entidad(
@router_rubro.get
(
'/{rubro_id}/entidades/map'
,
response_model
=
List
[
schemas
.
treemap
.
TreemapRubroSingle
])
@not_found
def
fetch_rubro_treemap
(
rubro_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -84,6 +90,7 @@ def fetch_rubro_treemap(
@router_rubro.get
(
'/{rubro_id}/entidades/{entidad_id}'
,
response_model
=
List
[
schemas
.
rubro
.
RubroEntidad
])
@not_found
def
fetch_rubro_entidad_single
(
rubro_id
:
str
,
entidad_id
:
int
,
...
...
@@ -99,6 +106,7 @@ def fetch_rubro_entidad_single(
@router_organismo.get
(
'/{organismo_id}'
,
response_model
=
schemas
.
organismo
.
ClasOrganismosEstados
)
@not_found
def
fetch_organismo_estado
(
organismo_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -118,6 +126,7 @@ def fetch_organismo_estado(
@router_organismo.get
(
'/{organismo_id}/entidades'
,
response_model
=
List
[
schemas
.
organismo
.
OrganismoEntidad
])
@not_found
def
fetch_organismo_entidad
(
organismo_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -135,6 +144,7 @@ def fetch_organismo_entidad(
@router_organismo.get
(
'/{organismo_id}/entidades/{entidad_id}'
,
response_model
=
List
[
schemas
.
organismo
.
OrganismoEntidad
])
@not_found
def
fetch_organismo_entidad_single
(
organismo_id
:
str
,
entidad_id
:
int
,
...
...
routers/daily.py
View file @
5e81514
...
...
@@ -5,6 +5,7 @@ from sqlalchemy.orm import Session, aliased
from
sqlalchemy
import
func
from
presupuestov1
import
model
,
schema
,
schemas
,
models
from
presupuestov1.routers._decorators
import
not_found
router
=
APIRouter
(
...
...
@@ -18,6 +19,7 @@ router = APIRouter(
###############################################################################
@router.get
(
'/status'
,
response_model
=
schemas
.
daily
.
UpdateStatus
)
@not_found
def
fetch_status
(
db
:
Session
=
Depends
(
model
.
get_db
),
):
...
...
@@ -28,6 +30,7 @@ def fetch_status(
@router.get
(
'/clasificadores'
,
response_model
=
List
[
schemas
.
daily
.
EjecucionClasificadores
])
@not_found
def
fetch_clasificadores
(
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
DailyParams
=
Depends
(),
...
...
@@ -44,6 +47,7 @@ def fetch_clasificadores(
@router.get
(
'/entidades'
,
response_model
=
List
[
schemas
.
daily
.
EjecucionEntidades
])
@not_found
def
fetch_entidades
(
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
DailyParams
=
Depends
(),
...
...
@@ -67,6 +71,7 @@ def fetch_entidades(
@router.get
(
'/timeline'
,
response_model
=
List
[
schemas
.
daily
.
Timeline
])
@not_found
def
fetch_timeline
(
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
DailyParams
=
Depends
(),
...
...
@@ -115,6 +120,7 @@ def fetch_timeline(
@router.get
(
'/timeseries'
,
response_model
=
List
[
schemas
.
daily
.
TimeSeries
])
@not_found
def
fetch_timeseries
(
db
:
Session
=
Depends
(
model
.
get_db
),
):
...
...
routers/entity.py
View file @
5e81514
...
...
@@ -7,6 +7,7 @@ from sqlalchemy.orm import Session
from
sqlalchemy
import
and_
,
or_
,
select
from
presupuestov1
import
model
,
schema
,
constant
,
schemas
,
models
,
search
from
presupuestov1.routers._decorators
import
not_found
router_entidad
=
APIRouter
(
...
...
@@ -30,6 +31,7 @@ router_da = APIRouter(
# clas
@router_entidad.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasInstitucional
])
@not_found
def
fetch_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
),
):
...
...
@@ -37,6 +39,7 @@ def fetch_classifier(
@router_ubigeo.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasGeografico
])
@not_found
def
fetch_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
),
):
...
...
@@ -47,6 +50,7 @@ def fetch_classifier(
# base
@router_entidad.get
(
'/{entity_id:str}'
,
response_model
=
schemas
.
entity
.
ClasInstitucionalIngresosGastos
)
@not_found
def
fetch_entity
(
entity_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -63,6 +67,7 @@ def fetch_entity(
@router_ubigeo.get
(
'/{ubigeo_id:str}'
,
response_model
=
schemas
.
entity
.
ClasGeograficoIngresosGastos
)
@not_found
def
fetch_entity
(
ubigeo_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
...
...
@@ -156,6 +161,7 @@ def fetch_entity_organismos(
# private
###############################################################################
@not_found
def
get_distribuciones
(
db
,
tipo_codigo
,
entity_id
,
dimension
,
query
):
EntidadDistribucionesSchema
=
schemas
.
entity
.
EntidadDistribucion
EntidadDistribuciones
=
models
.
entity
.
EntidadDistribuciones
...
...
Please
register
or
login
to post a comment