Skip to content

Commit

Permalink
old stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Jul 18, 2024
1 parent 3a42123 commit a43bc30
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
17 changes: 17 additions & 0 deletions linguaphoto/crud/transcriptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Defines CRUD interface for transcriptions API."""

import asyncio
import uuid
from io import BytesIO

from PIL import Image

from linguaphoto.crud.base import BaseCrud
from linguaphoto.settings import settings




class ImagesCrud(BaseCrud):
async def add_image_transcription(self, transcription_id: uuid.UUID, image_id: uuid.UUID, img: Image.Image) -> None:
asdf
11 changes: 11 additions & 0 deletions linguaphoto/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ async def create_tables(crud: Crud | None = None, deletion_protection: bool = Fa
],
deletion_protection=deletion_protection,
),
crud._create_dynamodb_table(
name="Transcriptions",
keys=[
("transcription_id", "S", "HASH"),
],
gsis=[
("userIndex", "user_id", "S", "HASH"),
("imagesIndex", "image_id", "S", "HASH"),
],
deletion_protection=deletion_protection,
),
)


Expand Down
37 changes: 11 additions & 26 deletions linguaphoto/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ class User(BaseModel):
user_id: str # Primary key
email: str

@classmethod
def from_uuid(cls, user_id: uuid.UUID, email: str) -> "User":
return cls(user_id=str(user_id), email=email)

def to_uuid(self) -> uuid.UUID:
return uuid.UUID(self.user_id)


class ApiKey(BaseModel):
"""Stored in Redis rather than DynamoDB."""
Expand All @@ -37,28 +30,20 @@ def from_api_key(cls, api_key: uuid.UUID, user_id: uuid.UUID, lifetime: int) ->
return cls(api_key_hash=api_key_hash, user_id=str(user_id), lifetime=lifetime)


class Bom(BaseModel):
part_id: str
quantity: int


class Image(BaseModel):
caption: str
image_id: str # Primary key
user_id: str
url: str


class Robot(BaseModel):
robot_id: str # Primary key
owner: str
name: str
description: str
bom: list[Bom]
images: list[Image]
class Transcription(BaseModel):
transcript: str
pinyin: str
translation: str


class Part(BaseModel):
part_id: str # Primary key
part_name: str
owner: str
description: str
images: list[Image]
class Transcriptions(BaseModel):
transcript_id: str # Primary key
image_id: str
user_id: str
transcriptions: list[Transcription]

0 comments on commit a43bc30

Please sign in to comment.