Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Notes to Deta Drive #22

Open
wants to merge 2 commits into
base: knotro
Choose a base branch
from

Conversation

rohanshiva
Copy link
Contributor

No description provided.

@@ -41,7 +42,11 @@ async def read_note(note_name: str, json: bool = False):
new_note = Note(name=note_name)
note_dict = new_note.dict()
note_key = urlsafe_key(note_name)
notes.put(note_dict, note_key)
drive_notes.put(note_name, note_dict["content"])
note_dict["last_modified"] = str(datetime.now())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this create a human readable string? I always used .strftime()

def db_update_note(note: Note):
note_dict = note.dict()
note_dict["content"] = bleach.clean(note_dict["content"])
notes.put(note_dict, urlsafe_key(note.name))

drive_notes.put(note_dict["name"], str(note_dict["content"]))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll have to put it under the url safe key e.g. urlsafe_key(note.name)?


else:
if note:
Copy link
Owner

@xeust xeust Jun 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this function, if it's only a backlink update, we don't need to read & write from drive (because the content itself doesn't change).

Maybe a slight refactor of db_update_note?

Or maybe 3 functions:

  1. update_note: calls 2 & 3
  2. drive_update_note: reads / writes from Drive
  3. db_update_note: reads / writes from Base

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants