| summaryrefslogtreecommitdiff | 
diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | src/bounty/bnt_generate_player.erl | 4 | ||||
| -rw-r--r-- | src/bounty/struct/bnt_bounty.erl | 93 | 
3 files changed, 96 insertions, 3 deletions
| @@ -138,7 +138,7 @@ $(DIALYZER_BASE_PLT_FILE):  debug_run: $(DIALYZER_BASE_PLT_FILE)  	$(MAKE) debug_rebuild  	cp $< $(DIALYZER_PLT_FILE) -	$(DIALYZER_EXEC) --add_to_plt --plt $(DIALYZER_PLT_FILE) -r $(BIN_DIR) +	$(DIALYZER_EXEC) --add_to_plt --get_warnings --plt $(DIALYZER_PLT_FILE) -r $(BIN_DIR)  	$(DIALYZER_EXEC) --check_plt --plt $(DIALYZER_PLT_FILE)  	$(DIALYZER_EXEC) --get_warnings $(ERL_SRC_FILES) $(PREPROCESSED_ERL_SRC_FILES)\  		--src --plt $(DIALYZER_PLT_FILE) diff --git a/src/bounty/bnt_generate_player.erl b/src/bounty/bnt_generate_player.erl index 73767b0..9e67527 100644 --- a/src/bounty/bnt_generate_player.erl +++ b/src/bounty/bnt_generate_player.erl @@ -15,8 +15,8 @@  -spec reserve_login (binary(), binary()) -> 'ok'.  reserve_login (UsernameLC, EmailLC) ->     Anyone = ataxia_security:allow_any(), -   ok = ataxia_client:reserve(login_db, Anyone, Anyone, UsernameLC), -   ok = ataxia_client:reserve(login_db, Anyone, Anyone, EmailLC), +   ok = ataxia_client:reserve_at(login_db, Anyone, Anyone, UsernameLC), +   ok = ataxia_client:reserve_at(login_db, Anyone, Anyone, EmailLC),     ok. diff --git a/src/bounty/struct/bnt_bounty.erl b/src/bounty/struct/bnt_bounty.erl new file mode 100644 index 0000000..0d7df47 --- /dev/null +++ b/src/bounty/struct/bnt_bounty.erl @@ -0,0 +1,93 @@ +-module(bnt_bounty). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: ataxia_id:type(). +-type job() :: {atom(), atom(), list(any())}. + +-record +( +   bounty, +   { +      deadline :: ataxia_time:type(), +      user :: ataxia_security:user(), +      job :: job() +   } +). + +-type type() :: #bounty{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( +   [ +      generate/4, +      execute/1 +   ] +). + +-export +( +   [ +      get_deadline/1, +      get_user/1, +      get_job/1 +   ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec generate +   ( +      ataxia_security:user(), +      ataxia_time:type(), +      ataxia_time:type(), +      job() +   ) +   -> 'ok'. +generate (User, NotBefore, Deadline, Job) -> +   Janitor = ataxia_security:janitor(), +   JanitorOnly = ataxia_security:allow_only(Janitor), + +   Bounty = +      { +         deadline = Deadline, +         user = User, +         job = Job +      }, + +   {ok, _BountyID} = +      ataxia_client:add +      ( +         bounty_db, +         JanitorOnly, +         JanitorOnly, +         ataxia_lock:locked(User, NotBefore), +         Bounty +      ), + +   ok. + +-spec execute (type()) -> any(). +execute (Bounty) -> +   {Module, Function, Params} = Bounty#bounty.job, +   erlang:apply(Module, Function, Params). + +-spec get_deadline (type()) -> ataxia_time:type(). +get_deadline (Bounty) -> Bounty#bounty.deadline. + +-spec get_user (type()) -> ataxia_security:user(). +get_user (Bounty) -> Bounty#bounty.user. + +-spec get_job (type()) -> job(). +get_job (Bounty) -> Bounty#bounty.job. | 


