-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add frontend dashboard endpoint & placeholder data
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from fastapi import APIRouter | ||
|
||
from ..db.conn import DIMainDB | ||
from ..schema.frontend import DashboardDataV1, DashboardEventDetailV1 | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.post("/fe/dashboard") | ||
async def get_dashboard_data_v1(main_db: DIMainDB) -> DashboardDataV1: | ||
# TODO: query the crunched numbers | ||
_ = main_db | ||
|
||
# this is placeholder data | ||
top_pkgs = { | ||
"toolchain/gnu-milkv-milkv-duo-musl-bin": DashboardEventDetailV1(total=4), | ||
"toolchain/gnu-upstream": DashboardEventDetailV1(total=3), | ||
"toolchain/gnu-plct": DashboardEventDetailV1(total=2), | ||
"board-image/buildroot-sdk-milkv-duo": DashboardEventDetailV1(total=1), | ||
} | ||
top_cmds = { | ||
"riscv64-unknown-linux-musl-gcc": DashboardEventDetailV1(total=100), | ||
"riscv64-unknown-linux-musl-g++": DashboardEventDetailV1(total=50), | ||
"riscv64-unknown-linux-musl-ld": DashboardEventDetailV1(total=5), | ||
} | ||
return DashboardDataV1( | ||
downloads=DashboardEventDetailV1(total=20), | ||
installs=DashboardEventDetailV1(total=5), | ||
top_packages=top_pkgs, | ||
top_commands=top_cmds, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class DashboardEventDetailV1(BaseModel): | ||
total: int | ||
|
||
|
||
class DashboardDataV1(BaseModel): | ||
downloads: DashboardEventDetailV1 | None | ||
installs: DashboardEventDetailV1 | None | ||
top_packages: dict[str, DashboardEventDetailV1 | None] | ||
top_commands: dict[str, DashboardEventDetailV1 | None] |