Skip to content

Commit

Permalink
Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM committed Nov 27, 2024
1 parent 813fc54 commit e212d60
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/mb/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,21 @@ async def search_records(query: QueryConfig = QueryConfig()):
),
)

@app.post("/stats")
async def aggregation_stats():
client = await async_elastic()
results = await client.search(
index="record",
query={"range": {"magnitude": {"gte": 1, "lte": 10}}},
aggs={
"magnitude": {"histogram": {"field": "magnitude", "interval": 1}},
"pga": {"histogram": {"field": "pga", "interval": 100}},
},
size=0,
)

return results["aggregations"]


@app.post("/index")
async def index_records(body: BulkRequest = Body(...), user: User = Depends(is_active)):
Expand Down

0 comments on commit e212d60

Please sign in to comment.