Skip to content

Instantly share code, notes, and snippets.

@whyvez
Forked from magdakosior/brainstorming.txt
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whyvez/bafa8a21bc6440155678 to your computer and use it in GitHub Desktop.
Save whyvez/bafa8a21bc6440155678 to your computer and use it in GitHub Desktop.
-- API --
validate_upload(upload_id) --inserts from get_upload_violations
exec delete_duplicates()upload_id -- iterate through eacj onValidate
insert from get_upload_violations(upload_id) into violations -- query on all rules without insert
delete_upload()
commit_upload() -- iterate through each onCommit in order
-- TERMS --
new-f = new feature
ex-f = existing feature
new-o = new ob
ex-ob = existing ob
onValidate = pre-validate (upload_id implied)
onCommit = post-validate
-- ORDER --
plot
onCommit:4:ex-f => delete from plot where not is_commited and key not in (select key from plot where is_commited)
onCommit:5:new-f_new-o => update w/ cascade from plot set is_commited = 'true' where upload_id = 'myid'
plot_measurement x
onValidate:2:ex-o => delete from plot_measurement where not is_commited and key not in (select key from plot_measurement where is_commited)
onCommit:6:new-o_ex-f => update w/ cascade from plot_measurement set is_commited = 'true' where upload_id = 'myid'
trees_measurement x
onValidate:1:ex-o => delete from trees_measurement where not is_commited and key not in (select key from trees_measurement where is_commited)
trees x
onCommit:1:ex-f => delete from trees where not is_commited and key not in (select key from trees where is_commited)
-- what happens with new trees? i.e. new-f_ex-f update??
trees_measurement x
onValidate:1:ex-o => delete from trees_measurement where not is_commited and key not in (select key from trees_measurement where is_commited)
treatment
onValidate:3:ex-o => delete from treatment where not is_commited and key not in (select key from treatment where is_commited)
onCommit:2:new-o_ex-f => update from treatment set is_commited = 'true' where key in (select key from treatment where not is_commited)
disturbance
onValidate:4:ex-o => delete from disturbance where not is_commited and key not in (select key from disturbance where is_commited)
onCommit:3:new-o_ex-f => update from treatment set is_commited = 'true' where key in (select key from treatment where not is_commited)
?? lets test above and define these later
regeneration
onValidate : delete from regeneration where not is_commited and key not in (select key from regeneration where is_commited)
onCommit: : update from regeneration set is_commited = 'true' where upload_id = 'myid'
photo_avi_layer
onValidate : delete from photo_avi_layer where not is_commited and key not in (select key from photo_avi_layer where is_commited)
onCommit: : update from photo_avi_layer set is_commited = 'true' where upload_id = 'myid'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment