Support to list snapshot
This commit is contained in:
@@ -8,6 +8,7 @@ from .database import API_ADD, API_UPDATE, API_DELETE
|
|||||||
from .database import ChangeSet
|
from .database import ChangeSet
|
||||||
from .database import get_current_operation
|
from .database import get_current_operation
|
||||||
from .database import execute_undo, execute_redo
|
from .database import execute_undo, execute_redo
|
||||||
|
from .database import list_snapshot
|
||||||
from .database import have_snapshot, have_snapshot_for_operation, have_snapshot_for_current_operation
|
from .database import have_snapshot, have_snapshot_for_operation, have_snapshot_for_current_operation
|
||||||
from .database import take_snapshot_for_operation, take_snapshot_for_current_operation, take_snapshot
|
from .database import take_snapshot_for_operation, take_snapshot_for_current_operation, take_snapshot
|
||||||
from .database import update_snapshot, update_snapshot_for_current_operation
|
from .database import update_snapshot, update_snapshot_for_current_operation
|
||||||
|
|||||||
@@ -162,6 +162,14 @@ def execute_redo(name: str) -> ChangeSet:
|
|||||||
return ChangeSet.from_list(e)
|
return ChangeSet.from_list(e)
|
||||||
|
|
||||||
|
|
||||||
|
def list_snapshot(name: str) -> list[tuple[int, str]]:
|
||||||
|
rows = read_all(name, f'select * from operation order by id')
|
||||||
|
result = []
|
||||||
|
for row in rows:
|
||||||
|
result.append((int(row['id']), str(row['tag'])))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def have_snapshot(name: str, tag: str) -> bool:
|
def have_snapshot(name: str, tag: str) -> bool:
|
||||||
return read(name, f"select id from snapshot_operation where tag = '{tag}'") != None
|
return read(name, f"select id from snapshot_operation where tag = '{tag}'") != None
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,9 @@ def execute_undo(name: str, discard: bool = False) -> ChangeSet:
|
|||||||
def execute_redo(name: str) -> ChangeSet:
|
def execute_redo(name: str) -> ChangeSet:
|
||||||
return api.execute_redo(name)
|
return api.execute_redo(name)
|
||||||
|
|
||||||
|
def list_snapshot(name: str) -> list[tuple[int, str]]:
|
||||||
|
return api.list_snapshot(name)
|
||||||
|
|
||||||
def have_snapshot(name: str, tag: str) -> bool:
|
def have_snapshot(name: str, tag: str) -> bool:
|
||||||
return api.have_snapshot(name, tag)
|
return api.have_snapshot(name, tag)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user