Compare commits
8
Commits
dc0d2acf53
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
847510319b | ||
|
|
72375db5cd | ||
|
|
5f48aba9cd | ||
|
|
ca07b161c7 | ||
|
|
9880b00fad | ||
|
|
eb20b68f03 | ||
|
|
041168ad02 | ||
|
|
6b458654a7 |
@@ -128,7 +128,6 @@ celerybeat.pid
|
|||||||
*.sage.py
|
*.sage.py
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
|
||||||
.venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ install:
|
|||||||
$(VENV_DIR)/bin/pip install -r $(REQ_FILE)
|
$(VENV_DIR)/bin/pip install -r $(REQ_FILE)
|
||||||
|
|
||||||
install-dev:
|
install-dev:
|
||||||
$(VENV_DIR)/bin/pip install -r $(REQ_FILE) -r requirements-dev.txt
|
$(VENV_DIR)/bin/pip install -r requirements-dev.txt
|
||||||
|
|
||||||
start:
|
start:
|
||||||
docker compose down -v db
|
docker compose down -v db
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ Welcome to this pair programming excercies for Axiomatic AI!
|
|||||||
|
|
||||||
This repository is a very minimal application that we have put together to test new candidates. The repository resembles how our codebase is structured but in a very much "cut down" fashion. As you will see, the application takes pieces from "clean architecture" standards and slims it down. It is by no means perfect (and neither is our real code) - if you see areas to improve, please mention them in the interview!
|
This repository is a very minimal application that we have put together to test new candidates. The repository resembles how our codebase is structured but in a very much "cut down" fashion. As you will see, the application takes pieces from "clean architecture" standards and slims it down. It is by no means perfect (and neither is our real code) - if you see areas to improve, please mention them in the interview!
|
||||||
|
|
||||||
During the pair programming excercise, you will be given some features, and be expected to implement them e2e. We are there to guide and help you! We do not expect you to achieve this goal, answering any questions you may need, or even helping with syntax.
|
During the pair programming excercise, you will be given some features, and be expected to implement them e2e. We are there to guide and help you! - answering any questions you may need, or even helping with syntax.
|
||||||
|
|
||||||
Please make sure to follow the `Dev Setup` section before the day of the interview so that we can help within any problems you may have.
|
Please make sure to follow the `Dev Setup` section before the day of the interview so that we can help with any problems you may have.
|
||||||
|
|
||||||
## Application Description
|
## Application Description
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ Go to `http://localhost:8080/docs` to see the Swagger UI
|
|||||||
|
|
||||||
There is a postgres database that powers the application. For simplicity, it is cleaned and re-seeded when you run `make start`. This means you do not have think about DB migrations. You can run `make clean-db` if you need to clean it manually.
|
There is a postgres database that powers the application. For simplicity, it is cleaned and re-seeded when you run `make start`. This means you do not have think about DB migrations. You can run `make clean-db` if you need to clean it manually.
|
||||||
|
|
||||||
## IDE Setup
|
## VSCode Setup
|
||||||
|
|
||||||
If you open the project directly within vscode, the debugger has been setup for you.
|
If you open the project directly within vscode, the debugger has been setup for you.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ENVIRONMENT=development
|
||||||
|
PG_USER=developer
|
||||||
|
PG_PASSWORD=password
|
||||||
|
PG_DB_NAME=dev
|
||||||
|
PG_HOST=localhost
|
||||||
|
PG_PORT=5432
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
from typing import Annotated
|
from typing import Annotated, Literal
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from fastapi import Depends
|
from fastapi import Depends
|
||||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||||
from sqlmodel import select
|
from sqlmodel import asc, desc, select
|
||||||
|
|
||||||
from ..models.house import House
|
from ..models.house import House
|
||||||
from ..providers.db_provider import get_session
|
from ..providers.db_provider import get_session
|
||||||
@@ -13,8 +13,19 @@ class HouseRepository:
|
|||||||
def __init__(self, session: Annotated[AsyncSession, Depends(get_session)]) -> None:
|
def __init__(self, session: Annotated[AsyncSession, Depends(get_session)]) -> None:
|
||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
async def get_all(self, limit: int = 100, offset: int = 0) -> list[House]:
|
async def get_all(
|
||||||
statement = select(House).offset(offset).limit(limit)
|
self,
|
||||||
|
limit: int = 100,
|
||||||
|
offset: int = 0,
|
||||||
|
order_by: Literal["PRICE"] = "PRICE",
|
||||||
|
sort_order: Literal["ASC", "DESC"] = "DESC",
|
||||||
|
) -> list[House]:
|
||||||
|
sorter = desc if sort_order == "DESC" else asc
|
||||||
|
|
||||||
|
statement = (
|
||||||
|
select(House).offset(offset).limit(limit).order_by(sorter(House.price))
|
||||||
|
)
|
||||||
|
|
||||||
result = await self.session.execute(statement)
|
result = await self.session.execute(statement)
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Annotated
|
from typing import Annotated, Literal
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
|
|
||||||
@@ -48,10 +48,14 @@ async def create_house(
|
|||||||
@router.get("")
|
@router.get("")
|
||||||
async def get_all_houses(
|
async def get_all_houses(
|
||||||
house_repository: Annotated[HouseRepository, Depends()],
|
house_repository: Annotated[HouseRepository, Depends()],
|
||||||
|
order_by: Literal["PRICE"] = "PRICE",
|
||||||
|
sort_order: Literal["ASC", "DESC"] = "DESC",
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
) -> HousesListResponse:
|
) -> HousesListResponse:
|
||||||
all_houses = await house_repository.get_all(offset=offset, limit=limit)
|
all_houses = await house_repository.get_all(
|
||||||
|
offset=offset, limit=limit, order_by=order_by, sort_order=sort_order
|
||||||
|
)
|
||||||
|
|
||||||
house_responses = [
|
house_responses = [
|
||||||
HouseResponse(
|
HouseResponse(
|
||||||
@@ -64,6 +68,5 @@ async def get_all_houses(
|
|||||||
)
|
)
|
||||||
for house in all_houses
|
for house in all_houses
|
||||||
]
|
]
|
||||||
print(house_responses)
|
|
||||||
|
|
||||||
return HousesListResponse(houses=house_responses)
|
return HousesListResponse(houses=house_responses)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
|
from ..models import User
|
||||||
|
|
||||||
|
|
||||||
class InvestorPredictor:
|
class InvestorPredictor:
|
||||||
def is_investor(user: User) -> bool:
|
def is_investor(user: User) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user