-
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.
- Loading branch information
Showing
29 changed files
with
320 additions
and
239 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,41 @@ | ||
from edgedb.asyncio_client import AsyncIOClient | ||
from faker import Faker | ||
|
||
fker = Faker() | ||
|
||
|
||
async def add_users(db_client: AsyncIOClient, target_n_users=5): | ||
""" | ||
faker.name() might produce the same name. Using `set` to make sure `target_n_users` can be achieved. | ||
""" | ||
names = set() | ||
while len(names) < target_n_users: | ||
names.add(fker.name()) | ||
|
||
await db_client.query( | ||
"""\ | ||
delete Event; | ||
delete User; | ||
for name in array_unpack(<array<str>>$names) | ||
union (insert User {name:= name});\ | ||
""", | ||
names=list(names), | ||
) | ||
|
||
|
||
async def add_events(db_client: AsyncIOClient, target_n_events=5): | ||
""" | ||
faker.text() might produce the same name. Using `set` to make sure `target_n_events` can be achieved. | ||
""" | ||
names = set() | ||
while len(names) < target_n_events: | ||
names.add(fker.text(max_nb_chars=20).rstrip(".")) | ||
|
||
await db_client.query( | ||
"""\ | ||
with dummy_user:= (insert User {name:= "dummy user"}), | ||
for name in array_unpack(<array<str>>$names) | ||
union (insert Event {name:= name, host:= dummy_user });\ | ||
""", | ||
names=list(names), | ||
) |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
from fastapi import APIRouter | ||
|
||
router = APIRouter(include_in_schema=False) | ||
|
||
|
||
@router.get("/") | ||
async def home(): | ||
return {"message": "Hello World from FastAPI"} |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from functools import partial | ||
|
||
import svcs | ||
|
||
from ._lifespan import _lifespan | ||
|
||
lifespan = svcs.fastapi.lifespan(_lifespan) | ||
lifespan = svcs.fastapi.lifespan(partial(_lifespan, prefill=True)) |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
select Event { | ||
name, | ||
created_at, | ||
address, | ||
schedule, | ||
host : {name} | ||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
select Event {name, address, schedule, host : {name}}; | ||
select Event {name, created_at, address, schedule, host : {name}}; |
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
select User {name, created_at} filter User.name=<str>$name; | ||
select User {name, | ||
created_at, | ||
n_events:= count(.<host[is Event]) | ||
} | ||
filter User.name=<str>$name; | ||
|
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 was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
app/queries/get_user_by_name_with_n_events_async_edgeql.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
select User {name, created_at}; | ||
select User {name, | ||
created_at, | ||
n_events:= count(.<host[is Event]) | ||
} |
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,27 @@ | ||
from fastapi import ( | ||
APIRouter, | ||
HTTPException, # noqa: F401 | ||
) | ||
from fastapi.responses import HTMLResponse | ||
from fastui import AnyComponent, FastUI, prebuilt_html | ||
from fastui import components as c | ||
from fastui.events import BackEvent, GoToEvent, PageEvent # noqa:F401 | ||
|
||
from .models import EventFull, UserFull # noqa: F401 | ||
from .shared import demo_page | ||
from .utils import _raise_for_status # noqa: F401 | ||
|
||
router = APIRouter(include_in_schema=False) | ||
|
||
|
||
@router.get("/api/", response_model=FastUI, response_model_exclude_none=True) | ||
async def home() -> list[AnyComponent]: | ||
return demo_page( | ||
c.Heading(text="Home", level=1), c.Paragraph(text="Hello World from FastUI") | ||
) | ||
|
||
|
||
@router.get("/{path:path}") | ||
async def html_landing() -> HTMLResponse: | ||
"""Simple HTML page which serves the React router, comes last as it matches all paths.""" | ||
return HTMLResponse(prebuilt_html(title="FastUI Demo")) |
Oops, something went wrong.