MastodonC/kixi.hecuba — pull request #29 by sw1nn (2014-05-23 18:15:13+00:00)
Title: validation re-work to dbnew.

This is the first cut of reworking the validation code to use the dbnew stuff, it s not currently ready to merge.

It is mostly there, but is untested. Raising the PR to allow discussion etc while people are in and out of office.

Main goal is to remove commander querier. This has a knockon effect all the way out to the pipeline.

Here are some thoughts on the structure/design of the code.

Ideally I want to start developing a clojure api to the database. A lot of this stuff exists in different places, it makes sense to identify common stuff and centralise it. I still expect and hope we will be able to write custom queries against the database when we need to, but things like 'find a sensor' 'give me a (lazy) seq of all measurements ' are common enough that we should aim for re-use. I'm particularly keen that any data base paging is embedded in a lazy seq so we don't end up re-inventing it everywhere.

I like ``update-sensor`` you can pass it a delta on top or something like ``{:errors (hayt/inc-by 1)}`` which is neato.

public fns should be passed a store from which they can open a session, *not* a session object. I expect nested sessions to work, so we shouldn't worry too about it. The ``validate`` fn demonstrates this patten. It creates a session then calls private fns passing it the session. I intend to develop tests that use this idiom to demonstrate that the correct calls to the db have been made.

There's still some muddlement about whether the where clause should be passed around or the sensor / measurement to be updated. TBD.