-
Notifications
You must be signed in to change notification settings - Fork 10
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
base: knotro
Are you sure you want to change the base?
Conversation
@@ -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()) |
There was a problem hiding this comment.
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"])) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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:
update_note
: calls 2 & 3drive_update_note
: reads / writes from Drivedb_update_note
: reads / writes from Base
No description provided.