Accept Merge Request #106: (api -> master)

Merge Request: Support restore operation

Created By: @王琼钰
Accepted By: @王琼钰
URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/106
This commit is contained in:
王琼钰
2022-11-26 00:13:22 +08:00
7 changed files with 25 additions and 11 deletions

View File

@@ -9,7 +9,7 @@ from .operation import ChangeSet
from .operation import get_current_operation
from .operation import execute_undo, execute_redo
from .operation import have_snapshot, take_snapshot, pick_snapshot
from .operation import pick_operation, sync_with_server
from .operation import pick_operation, sync_with_server, get_restore_operation
from .command import execute_batch_command, execute_batch_commands

View File

@@ -307,3 +307,7 @@ def sync_with_server(name: str, operation: int) -> ChangeSet:
index -= 1
return change.compress()
def get_restore_operation(name: str) -> int:
return read(name, f'select * from restore_operation')['id']

View File

@@ -221,7 +221,9 @@ def read_inp(project: str, inp: str):
create_project(project)
open_project(project)
execute_batch_command(project, _read_inp(inp))
execute_batch_commands(project, _read_inp(inp))
op = get_current_operation(project)
write(project, f'update restore_operation set id = {op}')
def dump_inp(project: str, inp: str):

View File

@@ -4,7 +4,7 @@ files = [
'bwsn',
'exnet',
'fengxian',
#'jbh', # too big sql to compress
'jbh',
'nanjing',
'net3',
'zj',
@@ -19,7 +19,5 @@ def db2inp():
dump_inp(file, f'db_{file}.inp')
if __name__ == '__main__':
#inp2db()
#db2inp()
print(run_project('net3'))
pass
inp2db()
db2inp()

View File

@@ -1,6 +1,6 @@
create table operation
(
id serial primary key
id bigserial primary key
, redo text not null
, undo text not null
, parent integer references operation(id) on delete cascade
@@ -13,13 +13,20 @@ insert into operation (id, redo, undo, redo_cs, undo_cs) values (0, '', '', '',
create table current_operation
(
id integer primary key references operation(id) -- must update before delete
id bigint primary key references operation(id) -- must update before delete
);
insert into current_operation (id) values (0);
create table snapshot_operation
(
id integer primary key references operation(id) on delete cascade
id bigint primary key references operation(id) on delete cascade
, tag text not null unique
);
create table restore_operation
(
id bigint primary key references operation(id) -- set after reading inp
);
insert into restore_operation (id) values (0);

View File

@@ -1,4 +1,4 @@
drop table if exists transaction_operation;
drop table if exists restore_operation;
drop table if exists snapshot_operation;

View File

@@ -179,6 +179,9 @@ def execute_batch_command(name: str, cs: ChangeSet) -> ChangeSet:
def execute_batch_commands(name: str, cs: ChangeSet) -> ChangeSet:
return api.execute_batch_commands(name, cs)
def get_restore_operation(name: str) -> int:
return api.get_restore_operation(name)
############################################################
# type