Skip to content

Commit

Permalink
added docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
LLkaia committed Jan 8, 2024
1 parent 01b9848 commit ad99ac1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
5 changes: 4 additions & 1 deletion fill_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@


async def fill():
"""Dump news corresponding to laptops"""
with open('laptop_models.json') as f:
laptops = json.load(f)
print('[INFO] loaded laptops')
print('[INFO] loaded laptops')

for i, laptop in enumerate(laptops):
name = (laptop.get('producer') + ' ' + laptop.get('model')).lower()
print(f'[INFO] process {i} laptop')
await update_search_results(name)


if __name__ == '__main__':
import asyncio
asyncio.run(fill())
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""start app"""
import uvicorn


Expand Down
5 changes: 0 additions & 5 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@

app = FastAPI()
app.include_router(SearchResultRouter, tags=["News"], prefix="/news")


@app.get('/', tags=['Root'])
async def read_root():
return {'message': 'Welcome!'}
3 changes: 1 addition & 2 deletions server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
MONGO_DETAILS = 'mongodb://mongodb:27017'
client = motor.motor_asyncio.AsyncIOMotorClient(MONGO_DETAILS)
db = client.lappy

search_results_collection = db.get_collection('search_results')


def search_results_helper(search_result):
"""Take each article and convert it to JSONable format"""
"""Convert each article to JSONable format"""
return {
"id": str(search_result["_id"]),
"link": search_result["link"],
Expand Down
1 change: 0 additions & 1 deletion server/models/search_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ArticleModel(BaseModel):
image: HttpUrl | None = None
date: datetime | None = None
description: str = ""
tags: set[str] = set()


class SearchResponseModel(BaseModel):
Expand Down

0 comments on commit ad99ac1

Please sign in to comment.