Closed nikolai-b closed 3 years ago
@AnnaGoodman1 I suggest we get rid of distances
and put it them all into journey_runs
. I would like to make sure we always have distance_in_traffic
for driving so we could add some custom trigger (untested):
CREATE OR REPLACE FUNCTION fn_distance_non_null_for_driving() RETURNS TRIGGER AS
$BODY$
BEGIN
IF (NEW.distance_in_traffic IS NULL AND runs.type = 'driving' JOIN runs ON run.id = NEW.run_id) THEN
RAISE not_null_violation;
END IF;
RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql;
CREATE CONSTRAINT TRIGGER fn_distance_non_null_for_driving
AFTER INSERT OR UPDATE
ON journey_runs
FOR EACH ROW EXECUTE PROCEDURE fn_distance_non_null_for_driving();
sounds great. so distance is there for all modes and distance_in_traffic is a) skipped of b) set as equal to distance for walk/cycle
both a) and b) options fine by me
From #10 : Also route by mode = walking and mode = cycling if day of month <=7 (i.e. do walking and cycling just the first Tuesday+Saturday of the month)