Skip to content

Commit

Permalink
history -> hist
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Nov 10, 2017
1 parent 5258b6d commit 1aeb860
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/api.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-spec complete(any(),pid()) -> {complete,any()}.
-spec amend(pid(),any()) -> {complete,any()}.
-spec event(pid(),any()) -> {complete,any()}.
-spec history(pid()) -> list(#history{}).
-spec hist(pid()) -> list(#hist{}).

% find task or document in process

Expand Down
6 changes: 3 additions & 3 deletions include/bpe.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
module=[] :: [] | atom()}).
-record(sequenceFlow, { source=[] :: [] | atom(),
target=[] :: [] | atom() }).
-record(history, { ?ITERATOR(feed),
-record(hist, { ?ITERATOR(feed),
name=[] :: [] | binary(),
task=[] :: atom(),
time=[] :: term() }).
-record(process, { ?ITERATOR(feed), name=[] :: [] | binary(),
roles=[] :: list(),
tasks=[] :: list(#task{} | #serviceTask{} | #userTask{} | #receiveTask{}),
events=[] :: list(#messageEvent{} | #boundaryEvent{} | #timeoutEvent{}),
history=[] :: [],
hist=[] :: [],
flows=[] :: list(#sequenceFlow{}),
rules=[] :: [],
docs=[] :: list(tuple()),
Expand All @@ -67,7 +67,7 @@

-record(complete, { id=[] :: [] | integer() }).
-record(proc, { id=[] :: [] | integer() }).
-record(hist, { id=[] :: [] | integer() }).
-record(histo, { id=[] :: [] | integer() }).
-record(create, { proc=[] :: [] | #process{} | binary(),
docs=[] :: [] | list(#join_application{} | #max_tour{} | #tour_list{}) }).
-record(amend, { id=[] :: [] | integer(),
Expand Down
10 changes: 5 additions & 5 deletions src/bpe.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

load(ProcName) -> {ok,Proc} = kvs:get(process,ProcName), Proc.

cleanup(P) -> [ kvs:remove(history,Id) || #history{id=Id} <- bpe:history(P) ],
kvs:delete(feed,{history,P}),
cleanup(P) -> [ kvs:remove(hist,Id) || #hist{id=Id} <- bpe:hist(P) ],
kvs:delete(feed,{hist,P}),
kvs:remove(process,P).

start(Proc0, Options) ->
Expand Down Expand Up @@ -55,9 +55,9 @@ delete_tasks(Proc, Tasks) ->
Proc#process { tasks = [ Task || Task <- Proc#process.tasks,
lists:member(Task#task.name,Tasks) ] }.

history(ProcId) -> history(ProcId,undefined).
history(ProcId,N) -> case kvs:entries(kvs:get(feed,{history,ProcId}),history,N) of
[] -> [#history{time=(bpe:load(ProcId))#process.started}];
hist(ProcId) -> hist(ProcId,undefined).
hist(ProcId,N) -> case kvs:entries(kvs:get(feed,{hist,ProcId}),hist,N) of
[] -> [#hist{time=(bpe:load(ProcId))#process.started}];
Res -> Res end.

source(Name, Proc) ->
Expand Down
4 changes: 2 additions & 2 deletions src/bpe_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ start(_StartType, _StartArgs) ->
stop(_State) -> ok.

worker(#process{id=Id}=P) ->
case bpe:history(Id) of
[H|_] -> worker_do(calendar:time_difference(H#history.time,calendar:local_time()),P);
case bpe:hist(Id) of
[H|_] -> worker_do(calendar:time_difference(H#hist.time,calendar:local_time()),P);
__ -> skip end.

worker_do({Days,Time},P) when Days >= 14 -> skip;
Expand Down
2 changes: 1 addition & 1 deletion src/bpe_metainfo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
metainfo() ->
#schema{name = bpe, tables = [
#table{name = process, fields=record_info(fields, process)},
#table{name = history, fields=record_info(fields, history)}
#table{name = hist, fields=record_info(fields, hist)}
% #table{name = sequenceFlow, fields=record_info(fields, sequenceFlow)},
% #table{name = userTask, fields=record_info(fields, userTask)},
% #table{name = serviceTask, fields=record_info(fields, serviceTask)},
Expand Down
4 changes: 2 additions & 2 deletions src/bpe_n2o.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ info(#amend{id=Proc,docs=Docs}=M,R,S) ->
n2o:info(?MODULE, "amend:~w",[M]),
{reply,{bert,{io,bpe:amend(Proc,Docs), <<>>}},R,S};

info(#hist{id=Proc}=M,R,S) ->
info(#histo{id=Proc}=M,R,S) ->
n2o:info(?MODULE, "hist:~w",[M]),
{reply,{bert,{io,bpe:history(Proc), <<>>}},R,S};
{reply,{bert,{io,bpe:hist(Proc), <<>>}},R,S};

info(#proc{id=Proc}=M,R,S) ->
n2o:info(?MODULE, "proc:~w",[M]),
Expand Down
12 changes: 6 additions & 6 deletions src/bpe_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ process_event(Event,Proc) ->
io:format("Event Targets: ~p",[Targets]),
{Status,{Reason,Target},ProcState} = bpe_event:handle_event(Event,bpe_task:find_flow(Targets),Proc),

kvs:add(#history { id = kvs:next_id("history",1),
feed_id = {history,ProcState#process.id},
kvs:add(#hist { id = kvs:next_id("hist",1),
feed_id = {hist,ProcState#process.id},
name = ProcState#process.name,
time = calendar:local_time(),
task = { event, element(#messageEvent.name,Event) }}),
Expand Down Expand Up @@ -50,8 +50,8 @@ process_flow(Stage,Proc,NoFlow) ->
{List,_,[]} -> bpe_task:handle_task(Task,Curr,bpe_task:find_flow(Stage,List),Proc);
{List,_,_} -> {reply,{complete,bpe_task:find_flow(Stage,List)},Proc} end,

kvs:add(#history { id = kvs:next_id("history",1),
feed_id = {history,ProcState#process.id},
kvs:add(#hist { id = kvs:next_id("hist",1),
feed_id = {hist,ProcState#process.id},
name = ProcState#process.name,
time = calendar:local_time(),
task = {task, Curr} }),
Expand Down Expand Up @@ -112,8 +112,8 @@ handle_info({timer,ping}, State=#process{task=Task,timer=Timer,id=Id,events=Even
Time2 = calendar:local_time(),
%kvs:info(?MODULE,"Ping: ~p, Task ~p, Event ~p, Record ~p ~n", [Id,Task,Name,Record]),

{DD,Diff} = case bpe:history(Id,1) of
[#history{time=Time1}] -> calendar:time_difference(Time1,Time2);
{DD,Diff} = case bpe:hist(Id,1) of
[#hist{time=Time1}] -> calendar:time_difference(Time1,Time2);
_ -> {immediate,timeout} end,

case {{DD,Diff} < {Days,Pattern}, Record} of
Expand Down

0 comments on commit 1aeb860

Please sign in to comment.