Skip to content

Commit 73aefb6

Browse files
committed
exporter.py: export revisions in chronological order
On the off-chance that revision order ever happens to matter, it will be FAR less surprising when the revisions are exported/imported in ascending chronological order.
1 parent 20e744c commit 73aefb6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

silicon/exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def export_page(title):
4848

4949
# get revisions
5050
revisions_data = []
51-
for timestamp in history(title):
51+
for timestamp in history(title, order='asc'):
5252
# for each timestamp, read the specific revision of the page
5353
# and append its timestamp and body to the revisions_data list
5454
revision_page = read(title, timestamp)

silicon/page.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,20 @@ def write(title, body, revision=None):
9292
return "Unable to save page"
9393

9494

95-
def history(title):
95+
def history(title, order='desc'):
9696
"""
9797
Return a list of all revisions of a title.
98+
99+
`order` is one of 'asc' or 'desc'.
98100
"""
99101

102+
if order == 'asc':
103+
sql_order = 'ASC'
104+
else:
105+
sql_order = 'DESC'
106+
100107
revisions = get_db().execute(
101-
"SELECT revision FROM pages WHERE title=? ORDER BY revision DESC",
108+
f"SELECT revision FROM pages WHERE title=? ORDER BY revision {sql_order}",
102109
(title,)
103110
).fetchall()
104111

0 commit comments

Comments
 (0)