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 18:46:33 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
783e6fac20eb0452e57b2e7fba4b49e38632b8fe
783e6fac
1 parent
3d04b7f4
XII
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
19 deletions
main.py
routers/classifier.py
routers/entity.py
routers/project.py
main.py
View file @
783e6fa
...
...
@@ -22,6 +22,7 @@ from presupuestov1.routers import (
classifier
,
classifier_income
,
daily
,
search
,
)
...
...
@@ -46,14 +47,13 @@ app = FastAPI(
CacheMiddleware
,
cache
=
cache
.
cache
,
rules
=
[
Rule
(
match
=
re
.
compile
(
r"^/api/
proyecto
/.*"
),
ttl
=
0
),
Rule
(
match
=
re
.
compile
(
r"^/api/
search
/.*"
),
ttl
=
0
),
Rule
(
match
=
re
.
compile
(
r'^/api/.+'
),
ttl
=
86400
,
status
=
200
),
],
),
],
root_path
=
'/api'
)
app
.
include_router
(
project
.
router
)
app
.
include_router
(
entity
.
router_entidad
)
app
.
include_router
(
entity
.
router_ubigeo
)
app
.
include_router
(
entity
.
router_da
)
...
...
@@ -62,8 +62,9 @@ app.include_router(classifier.router_acteco)
app
.
include_router
(
classifier
.
router_finfun
)
app
.
include_router
(
classifier_income
.
router_rubro
)
app
.
include_router
(
classifier_income
.
router_organismo
)
app
.
include_router
(
project
.
router
)
app
.
include_router
(
daily
.
router
)
app
.
include_router
(
search
.
router
)
# @app.on_event('startup')
...
...
routers/classifier.py
View file @
783e6fa
...
...
@@ -32,19 +32,19 @@ router_finfun = APIRouter(
@router_objeto.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasObjetos
])
@not_found
def
fetch_obje
ct
_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
)):
def
fetch_obje
to
_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
)):
def
fetch_
acteco
_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
)):
def
fetch_
finfun
_classifier
(
db
:
Session
=
Depends
(
model
.
get_db
)):
return
_fetch_classifier
(
'finfun'
,
db
)
...
...
routers/entity.py
View file @
783e6fa
...
...
@@ -32,7 +32,7 @@ router_da = APIRouter(
@router_entidad.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasInstitucional
])
@not_found
def
fetch_classifier
(
def
fetch_
entidad_
classifier
(
db
:
Session
=
Depends
(
model
.
get_db
),
):
return
db
.
query
(
models
.
classifier
.
ClasInstitucional
)
.
all
()
...
...
@@ -40,7 +40,7 @@ def fetch_classifier(
@router_ubigeo.get
(
'/clasificador'
,
response_model
=
List
[
schemas
.
classifier
.
ClasGeografico
])
@not_found
def
fetch_classifier
(
def
fetch_
ubigeo_
classifier
(
db
:
Session
=
Depends
(
model
.
get_db
),
):
return
db
.
query
(
models
.
classifier
.
ClasGeografico
)
.
all
()
...
...
@@ -51,7 +51,7 @@ def fetch_classifier(
@router_entidad.get
(
'/{entity_id:str}'
,
response_model
=
schemas
.
entity
.
ClasInstitucionalIngresosGastos
)
@not_found
def
fetch_enti
ty
(
def
fetch_enti
dad
(
entity_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
):
...
...
@@ -68,7 +68,7 @@ def fetch_entity(
@router_ubigeo.get
(
'/{ubigeo_id:str}'
,
response_model
=
schemas
.
entity
.
ClasGeograficoIngresosGastos
)
@not_found
def
fetch_
entity
(
def
fetch_
ubigeo
(
ubigeo_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
):
...
...
@@ -83,10 +83,20 @@ def fetch_entity(
return
ubigeo
@router_da.get
(
'/{da_id:str}'
,
response_model
=
List
[
schemas
.
entity
.
EntidadResumen
])
@not_found
def
fetch_da
(
da_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
):
gastos_ingresos
=
get_resumen
(
db
,
'entidad_da'
,
ubigeo_id
)
return
gastos_ingresos
# objetos
@router_entidad.get
(
'/{entity_id:str}/objetos'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_enti
ty
_objetos
(
def
fetch_enti
dad
_objetos
(
entity_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
@@ -95,7 +105,7 @@ def fetch_entity_objetos(
@router_ubigeo.get
(
'/{ubigeo_id:str}/objetos'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_
entity
_objetos
(
def
fetch_
ubigeo
_objetos
(
ubigeo_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
@@ -103,8 +113,17 @@ def fetch_entity_objetos(
return
get_distribuciones
(
db
,
'municipio_ubigeo'
,
ubigeo_id
,
'objeto'
,
query
)
@router_da.get
(
'/{da_id:str}/objetos'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_da_objetos
(
da_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
):
return
get_distribuciones
(
db
,
'entidad_da'
,
da_id
,
'objeto'
,
query
)
@router_entidad.get
(
'/{entity_id:str}/finfuns'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_enti
ty
_finfuns
(
def
fetch_enti
dad
_finfuns
(
entity_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
@@ -113,7 +132,7 @@ def fetch_entity_finfuns(
@router_ubigeo.get
(
'/{ubigeo_id:str}/finfuns'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_
entity
_finfuns
(
def
fetch_
ubigeo
_finfuns
(
ubigeo_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
@@ -121,8 +140,17 @@ def fetch_entity_finfuns(
return
get_distribuciones
(
db
,
'municipio_ubigeo'
,
ubigeo_id
,
'finfun'
,
query
)
@router_da.get
(
'/{da_id:str}/finfuns'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_da_finfuns
(
da_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
):
return
get_distribuciones
(
db
,
'entidad_da'
,
da_id
,
'finfun'
,
query
)
@router_entidad.get
(
'/{entity_id:str}/actecos'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_enti
ty
_actecos
(
def
fetch_enti
dad
_actecos
(
entity_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
@@ -131,7 +159,7 @@ def fetch_entity_actecos(
@router_ubigeo.get
(
'/{ubigeo_id:str}/actecos'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_
entity
_actecos
(
def
fetch_
ubigeo
_actecos
(
ubigeo_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
@@ -139,8 +167,17 @@ def fetch_entity_actecos(
return
get_distribuciones
(
db
,
'municipio_ubigeo'
,
ubigeo_id
,
'acteco'
,
query
)
@router_da.get
(
'/{da_id:str}/actecos'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_da_actecos
(
da_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
):
return
get_distribuciones
(
db
,
'entidad_da'
,
da_id
,
'acteco'
,
query
)
@router_entidad.get
(
'/{entity_id:str}/rubros'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_enti
ty
_rubros
(
def
fetch_enti
dad
_rubros
(
entity_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
@@ -149,7 +186,7 @@ def fetch_entity_rubros(
@router_entidad.get
(
'/{entity_id:str}/organismos'
,
response_model
=
List
[
schemas
.
entity
.
EntidadDistribucion
])
def
fetch_enti
ty
_organismos
(
def
fetch_enti
dad
_organismos
(
entity_id
:
str
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
routers/project.py
View file @
783e6fa
...
...
@@ -6,6 +6,7 @@ from fastapi import APIRouter, Depends, Request, HTTPException, Body
from
sqlalchemy.orm
import
Session
from
presupuestov1
import
model
,
schema
,
constant
,
schemas
,
models
,
search
from
presupuestov1.routers._decorators
import
not_found
router
=
APIRouter
(
...
...
@@ -29,7 +30,7 @@ def fetch_programa_proyecto(
@router.get
(
'/{project_id}/proyectos'
)
@not_found
def
fetch_programa_proyecto_pro
j
ectos
(
def
fetch_programa_proyecto_pro
y
ectos
(
project_id
:
int
,
db
:
Session
=
Depends
(
model
.
get_db
),
query
:
schema
.
QueryParams
=
Depends
(),
...
...
Please
register
or
login
to post a comment