Compare commits

...
8 Commits
Author SHA1 Message Date
jcbwndsrandGitHub 847510319b Update README.md 2025-02-20 14:20:46 +01:00
jcbwndsrandGitHub 72375db5cd Update README.md 2025-02-20 14:20:34 +01:00
jcbwndsrandGitHub 5f48aba9cd Update Makefile to only install dev requirements 2025-02-20 11:33:08 +01:00
jcbwndsrandGitHub ca07b161c7 Update README to be specific about vscode 2025-02-20 11:31:51 +01:00
Jacob Windsor 9880b00fad Add .env 2025-02-19 18:34:08 +01:00
jcbwndsrandGitHub eb20b68f03 Merge pull request #1 from Axiomatic-AI/try-excercise
Add some fixes after trying the excercise
2025-02-19 18:27:03 +01:00
Jacob Windsor 041168ad02 Fix import 2025-02-19 17:52:17 +01:00
Jacob Windsor 6b458654a7 Add sorting 2025-02-19 17:52:11 +01:00
7 changed files with 33 additions and 12 deletions
-1
View File
@@ -128,7 +128,6 @@ celerybeat.pid
*.sage.py
# Environments
.env
.venv
env/
venv/
+1 -1
View File
@@ -10,7 +10,7 @@ install:
$(VENV_DIR)/bin/pip install -r $(REQ_FILE)
install-dev:
$(VENV_DIR)/bin/pip install -r $(REQ_FILE) -r requirements-dev.txt
$(VENV_DIR)/bin/pip install -r requirements-dev.txt
start:
docker compose down -v db
+3 -3
View File
@@ -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!
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
@@ -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.
## IDE Setup
## VSCode Setup
If you open the project directly within vscode, the debugger has been setup for you.
+6
View File
@@ -0,0 +1,6 @@
ENVIRONMENT=development
PG_USER=developer
PG_PASSWORD=password
PG_DB_NAME=dev
PG_HOST=localhost
PG_PORT=5432
+15 -4
View File
@@ -1,9 +1,9 @@
from typing import Annotated
from typing import Annotated, Literal
from uuid import UUID
from fastapi import Depends
from sqlalchemy.ext.asyncio.session import AsyncSession
from sqlmodel import select
from sqlmodel import asc, desc, select
from ..models.house import House
from ..providers.db_provider import get_session
@@ -13,8 +13,19 @@ class HouseRepository:
def __init__(self, session: Annotated[AsyncSession, Depends(get_session)]) -> None:
self.session = session
async def get_all(self, limit: int = 100, offset: int = 0) -> list[House]:
statement = select(House).offset(offset).limit(limit)
async def get_all(
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)
return result.scalars().all()
+6 -3
View File
@@ -1,4 +1,4 @@
from typing import Annotated
from typing import Annotated, Literal
from fastapi import APIRouter, Depends
@@ -48,10 +48,14 @@ async def create_house(
@router.get("")
async def get_all_houses(
house_repository: Annotated[HouseRepository, Depends()],
order_by: Literal["PRICE"] = "PRICE",
sort_order: Literal["ASC", "DESC"] = "DESC",
limit: int = 100,
offset: int = 0,
) -> 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 = [
HouseResponse(
@@ -64,6 +68,5 @@ async def get_all_houses(
)
for house in all_houses
]
print(house_responses)
return HousesListResponse(houses=house_responses)
@@ -1,5 +1,7 @@
import random
from ..models import User
class InvestorPredictor:
def is_investor(user: User) -> bool: