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-20 17:00:53 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4499ce422dc7e43773b2aa7ff63f3afcd91139d8
4499ce42
1 parent
72380414
XIV
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
22 deletions
cache.py
main.py
metrics.py
models/classifier.py
models/treemap.py
routers/classifier.py
routers/daily.py
schemas/classifier.py
schemas/objeto.py
search.py
cache.py
View file @
4499ce4
...
...
@@ -8,12 +8,12 @@ from aiocache import Cache
REDIS_CONN
=
open
(
'./docs/redis'
)
.
read
()
.
strip
()
REDIS_CONN
=
REDIS_CONN
.
split
(
':'
)
#
cache = Cache(
#
Cache.REDIS,
#
endpoint=REDIS_CONN[0], port=REDIS_CONN[1],
# namespace="httpcache"
#
)
cache
=
Cache
()
cache
=
Cache
(
Cache
.
REDIS
,
endpoint
=
REDIS_CONN
[
0
],
port
=
REDIS_CONN
[
1
],
namespace
=
'httpcache'
)
#
cache = Cache()
def
patched_generate_cache_key
(
url
,
method
,
headers
,
varying_headers
,
cache
):
...
...
main.py
View file @
4499ce4
...
...
@@ -63,7 +63,7 @@ app.include_router(daily.router)
app
.
include_router
(
search
.
router
)
app
.
include_router
(
private_metrics
.
router
)
#
metrics.install(app)
metrics
.
install
(
app
)
# @app.on_event('startup')
...
...
metrics.py
View file @
4499ce4
...
...
@@ -385,14 +385,14 @@ def get_header_value(headers, key):
def
get_client_ip
(
headers
):
forwarded_for
=
get_header_value
(
headers
,
b
"x-forwarded-for"
)
if
forwarded_for
:
return
forwarded_for
.
split
(
","
,
1
)[
0
]
.
strip
()
real_ip
=
get_header_value
(
headers
,
b
"x-real-ip"
)
if
real_ip
:
return
real_ip
.
strip
()
forwarded_for
=
get_header_value
(
headers
,
b
"x-forwarded-for"
)
if
forwarded_for
:
return
forwarded_for
.
split
(
","
,
1
)[
0
]
.
strip
()
return
None
...
...
models/classifier.py
View file @
4499ce4
...
...
@@ -143,15 +143,15 @@ class ClasOrganismos(Base):
{
"schema"
:
"web"
},
)
organismo
:
Mapped
[
int
]
=
mapped_column
(
Integer
,
primary_key
=
True
)
organismo
:
Mapped
[
str
]
=
mapped_column
(
String
(
16
)
,
primary_key
=
True
)
desc_organismo
:
Mapped
[
str
]
=
mapped_column
(
Text
)
sigla_organismo
:
Mapped
[
str
]
=
mapped_column
(
String
(
20
))
organismo_grupo
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
organismo_grupo
:
Mapped
[
str
]
=
mapped_column
(
String
(
8
)
)
desc_organismo_grupo
:
Mapped
[
str
]
=
mapped_column
(
Text
)
sigla_organismo_grupo
:
Mapped
[
str
]
=
mapped_column
(
String
(
20
))
organismo_subgrupo
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
organismo_subgrupo
:
Mapped
[
str
]
=
mapped_column
(
String
(
4
)
)
desc_organismo_subgrupo
:
Mapped
[
str
]
=
mapped_column
(
Text
)
sigla_organismo_subgrupo
:
Mapped
[
str
]
=
mapped_column
(
String
(
20
))
...
...
models/treemap.py
View file @
4499ce4
...
...
@@ -27,6 +27,7 @@ class TreemapObjeto(Base):
gestion
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
9
))
desc_entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
entidad
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
objeto
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
nivel
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
20
))
...
...
@@ -53,6 +54,7 @@ class TreemapFinFun(Base):
gestion
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
9
))
desc_entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
entidad
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
finfun
:
Mapped
[
str
]
=
mapped_column
(
String
(
9
))
nivel
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
20
))
...
...
@@ -79,6 +81,7 @@ class TreemapActeco(Base):
gestion
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
9
))
desc_entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
entidad
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
acteco
:
Mapped
[
str
]
=
mapped_column
(
String
(
9
))
nivel
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
20
))
...
...
@@ -105,6 +108,7 @@ class TreemapRubro(Base):
gestion
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
9
))
desc_entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
entidad
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
rubro
:
Mapped
[
str
]
=
mapped_column
(
String
(
9
))
nivel
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
20
))
...
...
@@ -116,6 +120,33 @@ class TreemapRubro(Base):
desc_rubro
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
class
TreemapOrganismo
(
Base
):
__tablename__
=
"treemap_organismo"
__table_args__
=
(
Index
(
"idx_treemap_rubro_organismo"
,
"organismo"
),
Index
(
"idx_treemap_organismo_organismo_gestion"
,
"organismo"
,
"gestion"
),
Index
(
"idx_treemap_organismo_gestion_entidad"
,
"gestion"
,
"entidad"
),
Index
(
"idx_treemap_organismo_nivel"
,
"nivel"
),
{
"schema"
:
"web"
},
)
# PK compuesta inferida para uso ORM
id
:
Mapped
[
int
]
=
mapped_column
(
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
gestion
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
9
))
desc_entidad_area
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
entidad
:
Mapped
[
int
]
=
mapped_column
(
Integer
)
organismo
:
Mapped
[
str
]
=
mapped_column
(
String
(
9
))
nivel
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
20
))
parent
:
Mapped
[
str
|
None
]
=
mapped_column
(
String
(
9
))
devengado
:
Mapped
[
float
|
None
]
=
mapped_column
(
Numeric
(
30
,
15
))
desc_entidad
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
desc_organismo
:
Mapped
[
str
|
None
]
=
mapped_column
(
Text
)
###############################################################################
# fns
###############################################################################
...
...
routers/classifier.py
View file @
4499ce4
...
...
@@ -4,7 +4,7 @@ from typing import List, Any, Optional, Union
from
fastapi
import
APIRouter
,
Depends
,
Request
,
HTTPException
,
Body
from
sqlalchemy.orm
import
Session
from
sqlalchemy
import
and_
,
or_
,
select
from
sqlalchemy
import
and_
,
or_
,
select
,
text
from
presupuestov1
import
model
,
schema
,
constant
,
schemas
,
models
,
search
from
presupuestov1.routers._decorators
import
not_found
...
...
routers/daily.py
View file @
4499ce4
...
...
@@ -2,7 +2,7 @@ from typing import List
from
fastapi
import
APIRouter
,
Depends
from
sqlalchemy.orm
import
Session
,
aliased
from
sqlalchemy
import
func
from
sqlalchemy
import
func
,
select
from
presupuestov1
import
model
,
schema
,
schemas
,
models
from
presupuestov1.routers._decorators
import
not_found
...
...
schemas/classifier.py
View file @
4499ce4
...
...
@@ -76,15 +76,15 @@ class ClasGeografico(ClasBase):
# Ingresos
class
ClasOrganismos
(
OrmBaseModel
):
organismo
:
int
organismo
:
str
desc_organismo
:
str
|
None
sigla_organismo
:
str
|
None
organismo_grupo
:
int
|
None
organismo_grupo
:
str
|
None
desc_organismo_grupo
:
str
|
None
sigla_organismo_grupo
:
str
|
None
organismo_subgrupo
:
int
|
None
organismo_subgrupo
:
str
|
None
desc_organismo_subgrupo
:
str
|
None
sigla_organismo_subgrupo
:
str
|
None
...
...
schemas/objeto.py
View file @
4499ce4
...
...
@@ -26,11 +26,11 @@ class ObjetoEstado(OrmBaseModel):
top1_entidad_desc
:
str
|
None
top1_monto
:
float
|
None
top1_pct
:
float
|
None
top2_entidad
:
int
|
None
|
str
top2_entidad
:
int
|
float
|
None
|
str
top2_entidad_desc
:
str
|
None
top2_monto
:
float
|
None
|
str
top2_pct
:
float
|
None
|
str
top3_entidad
:
int
|
None
|
str
top3_entidad
:
int
|
float
|
None
|
str
top3_entidad_desc
:
str
|
None
top3_monto
:
float
|
None
|
str
top3_pct
:
float
|
None
|
str
...
...
search.py
View file @
4499ce4
...
...
@@ -6,6 +6,7 @@ import typesense
from
typesense
import
exceptions
as
typesense_exceptions
TYPESENSE_API
=
open
(
'./docs/typesense'
)
.
read
()
.
strip
()
TYPESENSE_API
,
TYPESENSE_HOST
=
TYPESENSE_API
.
split
(
':'
)
client
=
typesense
.
Client
({
'api_key'
:
TYPESENSE_API
,
'nodes'
:
[{
...
...
@@ -13,7 +14,7 @@ client = typesense.Client({
'port'
:
'8108'
,
'protocol'
:
'http'
}],
'connection_timeout_seconds'
:
0.5
'connection_timeout_seconds'
:
1.
})
COLLECTION
=
'presup_actpro_fts'
...
...
Please
register
or
login
to post a comment