Skip to content
Snippets Groups Projects
Commit 8600358a authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Sort entries by date

parent c4c4be61
No related tags found
No related merge requests found
Pipeline #10539 passed with stage
in 1 minute and 58 seconds
...@@ -50,9 +50,12 @@ def upgrade(): ...@@ -50,9 +50,12 @@ def upgrade():
username=db.types.text, date=db.types.datetime, source=db.types.text username=db.types.text, date=db.types.datetime, source=db.types.text
) )
# Sort the entries by date
sorted_users = sorted(users.values(), key=lambda d: d["date"])
# Insert into database in chunks # Insert into database in chunks
table = db["user_created"] table = db["user_created"]
table.insert_many(list(users.values()), ensure=True, types=data_types) table.insert_many(sorted_users, ensure=True, types=data_types)
if __name__ == "__main__": if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment