def fake_note() -> Iterator[Note]: while True: yield Note( note_id=uuid4(), meeting_id=uuid4(), time_stamp=int(time.time()), content_text=fake.pystr(), )
def get_note(self, note_id: uuid.UUID) -> Option[Note]: c = self.connection.cursor() c.execute("SELECT * FROM notes WHERE note_id=%s", (str(note_id),)) note = None res = c.fetchone() if res: note = Note(note_id, uuid.UUID(res[1]), res[2], res[3]) return maybe(note)
def get_notes_of_meeting(self, meeting_id: uuid.UUID) -> List[Note]: c = self.connection.cursor() c.execute("SELECT * FROM notes WHERE meeting_id=%s", (str(meeting_id),)) notes = c.fetchall() if len(notes) > 0: notes = map( lambda res: Note(uuid.UUID(res[0]), uuid.UUID(res[1]), res[2], res[3]), notes, ) return list(notes)
def create_note(self, meeting_id: UUID, author: Instructor, content_text: str) -> Result[Note, str]: """ Create a new note for the meeting <meeting_id>. Returns: The new Note created """ check_user = self._check_meeting_user( meeting_id, author, "Cannot make a not on meetings that you don't belong to") if not check_user: return check_user time_stamp = int(time.time()) note = Note(uuid4(), meeting_id, time_stamp, content_text) return self.meeting_persistence.create_note(note)