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

Sort by date #57

Closed
ego-lay-atman-bay opened this issue Mar 10, 2024 · 6 comments
Closed

Sort by date #57

ego-lay-atman-bay opened this issue Mar 10, 2024 · 6 comments
Assignees

Comments

@ego-lay-atman-bay
Copy link

Currently we can sort by title, but not by date. It would be great to sort by most recent, as sometimes I type a notr, go out, and then I can't find the note anymore because I have too many with the title "Note", so it would be rrally nice to be able to sort by date, and have the most recent edits at the top.

@jjewuz
Copy link
Owner

jjewuz commented Mar 10, 2024

Notes sorting by date currently.

@jjewuz jjewuz closed this as completed Mar 10, 2024
@jjewuz jjewuz self-assigned this Mar 10, 2024
@ego-lay-atman-bay
Copy link
Author

Well, how do I enable it, because the notes are sorting alphabetically in version 5.0.4 on my device

@jjewuz
Copy link
Owner

jjewuz commented Mar 10, 2024

Well, how do I enable it, because the notes are sorting alphabetically in version 5.0.4 on my device

do screenrecord and send to [email protected] (or attach there if no secure info in notes) where you add new note and then edit old

@ego-lay-atman-bay
Copy link
Author

After some more testing, it seems that it is sorting by date, but not very well. There are many months mixed with each other, as well as years. Here's a recording with it all (I edited a backup to remove all the titles to preserve privacy).

notes.mp4

@jjewuz
Copy link
Owner

jjewuz commented Mar 10, 2024

After some more testing, it seems that it is sorting by date, but not very well. There are many months mixed with each other, as well as years. Here's a recording with it all (I edited a backup to remove all the titles to preserve privacy).

notes.mp4

There have been several updates that have changed the sorting rules, so older notes made before these updates may not sort correctly. It is recommended to resave them.

@ego-lay-atman-bay
Copy link
Author

ego-lay-atman-bay commented Mar 10, 2024

It is recommended to resave them.

Seeing as how I have a ton of notes, that'll take me forever to manually do it all. How does the timestamp work, so I can try and write a script to convert the old date to the new format automatically? Or can you just add code to the app to update the database, so no one has to run into this issue? That is probably the best move on the app developer.

edit: I wrote this quick python script to update my notes database. If anyone else is running into this same issue, you can use it.

from datetime import datetime
import sqlite3
import sys
import traceback

DATE_FORMAT = "%d %b, %Y - %H:%M"

def main():
  args = sys.argv[1::]
  connection = sqlite3.connect(args[0])
  cursor = connection.cursor()
  rows = cursor.execute("SELECT id, timestamp FROM notesTable").fetchall()
  
  for id, time in rows:
    try:
      date = datetime.strptime(time, DATE_FORMAT)
      timestamp = date.timestamp() * 1000
      
      print(f"date: {time}")
      print(f"timestamp: {timestamp:.0f}")
      cursor.execute(f"UPDATE notesTable SET timestamp = {timestamp:.0f} WHERE id = {id}")
      connection.commit()
    except ValueError:
      traceback.print_exc()
      
if __name__ == "__main__":
  main()

@jjewuz jjewuz pinned this issue Mar 11, 2024
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

No branches or pull requests

2 participants