Create an interface for adding Trigger to an experiment - step 1
Summary
Sometimes scientist want to build and update websites based on the collected data. Whenever new results are send to lou-server
it can call a trigger (a GET or POST request to a remote url, usually carrying an authentification token), which in turn starts a script, which then fetches all results from the lou-server
instance and rebuilds the website.
Right now there's only very basic support for this - the environment variables EXPERIMENT_TRIGGER_URL
and EXPERIMENT_TRIGGER_DATA
are used to configure a single optional trigger, which is called, whenever new results are send to the server.
See config/experiment.php and app/Observers/ResultTrigger.php
The trigger can then call the the results-API in order to fetch all results.
It would be nice to have an interface, with which scientists can create, update, delete and run as many triggers as they like.
Step 1: Creating a Trigger
model, a migration, a controller and views to manage all CRUD actions. (Best to use separate commits for each).
-
Create Trigger
Model and a migration, which creates atriggers
table for our model. Fields:url
(string, cannot be empty),method
(string, cannot be empty),payload
(text, should be valid JSON, can be empty, cast toarray
). -
Create a TriggerController
as resource controller (php artisan make:controller -r ...
) and views, which can be used to display, create, update and delete these triggers. (Maybe one commit for each?) -
For the store
andupdate
route: Use input validation by defininingStoreTrigger
andUpdateTrigger
form request classes inapp/Http/Requests
(you can find examples here) and including them as type hints in theTriggerController
, e.g.public function store(StoreTrigger $request) { ... }
.