Skip to content

Commit

Permalink
fill db
Browse files Browse the repository at this point in the history
  • Loading branch information
LLkaia committed Jan 8, 2024
1 parent 55f94d9 commit b836b4e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions fill_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json

from server.database import update_search_results


async def fill():
with open('laptop_models.json') as f:
laptops = json.load(f)
print('[INFO] loaded laptops')
for i, laptop in enumerate(laptops):
name = laptop.get('producer') + ' ' + laptop.get('model')
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 laptop_models.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ async def update_search_results(search: str):
add search words to article's 'tags' field. Else, article will
be added to a database.
:param search: Search query
:return: List of articles added to a database
"""
results = scrap_from_search(search)
for result in results:
Expand Down

0 comments on commit b836b4e

Please sign in to comment.