Accept Merge Request #171: (list-snapshot -> master)
Merge Request: Support to list snapshot Created By: @王琼钰 Accepted By: @王琼钰 URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/171?initial=true
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 get_current_operation
|
||||
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 take_snapshot_for_operation, take_snapshot_for_current_operation, take_snapshot
|
||||
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)
|
||||
|
||||
|
||||
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:
|
||||
return try_read(name, f"select id from snapshot_operation where tag = '{tag}'") != None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user