{"action":"created","comment":{"url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/comments/28345632","id":28345632,"diff_hunk":"@@ -1,12 +1,39 @@\n (ns madetomeasure-api.routes.subscribers\n   (:require [madetomeasure-api.layout :as layout]\n-            [compojure.core :refer [defroutes GET POST DELETE PATCH]]))\n+            [madetomeasure-api.db.core :as db]\n+            [cheshire.core :refer :all]\n+            [compojure.core :refer [defroutes GET POST DELETE PATCH]]\n+            [madetomeasure-api.middleware.validate-json :refer [json-schema-validate]])\n+  (:import java.sql.SQLException))\n+\n+(def default-subscriber-map\n+  ^{:private true}\n+  {:first_name nil :last_name nil})","path":"src/madetomeasure_api/routes/subscribers.clj","position":13,"original_position":12,"commit_id":"a094b33fb0a73edd2b41fe3e29604623179e3b58","original_commit_id":"27763ded890e2b606805cd6cc92867b7d0e5dfa1","user":{"login":"hexgnu","id":138510,"avatar_url":"https://avatars.githubusercontent.com/u/138510?v=3","gravatar_id":"","url":"https://api.github.com/users/hexgnu","html_url":"https://github.com/hexgnu","followers_url":"https://api.github.com/users/hexgnu/followers","following_url":"https://api.github.com/users/hexgnu/following{/other_user}","gists_url":"https://api.github.com/users/hexgnu/gists{/gist_id}","starred_url":"https://api.github.com/users/hexgnu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hexgnu/subscriptions","organizations_url":"https://api.github.com/users/hexgnu/orgs","repos_url":"https://api.github.com/users/hexgnu/repos","events_url":"https://api.github.com/users/hexgnu/events{/privacy}","received_events_url":"https://api.github.com/users/hexgnu/received_events","type":"User","site_admin":false},"body":"So something that I find interesting about yesql is that it requires that you have all parameters even if they are null.\r\n\r\nFor instance if I send\r\n\r\n`{:address \"flap@gums.com\"}` yesql will barf and say hey you didn't add first_name / last_name.\r\n\r\nI think this is actually kind of a feature in a way cause it makes you explicitly say that the default-subscriber is `{:first_name nil :last_name nil}` which you then can merge into whatever is pushed in.\r\n\r\nPotentially we could leave it as is but it'd require people to fill out first_name=null last_name=null which I think is kind of weird","created_at":"2015-04-14T16:49:01Z","updated_at":"2015-04-14T16:49:01Z","html_url":"https://github.com/madetomeasure/madetomeasure/pull/1#discussion_r28345632","pull_request_url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/comments/28345632"},"html":{"href":"https://github.com/madetomeasure/madetomeasure/pull/1#discussion_r28345632"},"pull_request":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1","id":33196504,"html_url":"https://github.com/madetomeasure/madetomeasure/pull/1","diff_url":"https://github.com/madetomeasure/madetomeasure/pull/1.diff","patch_url":"https://github.com/madetomeasure/madetomeasure/pull/1.patch","issue_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/1","number":1,"state":"open","locked":false,"title":"Create subscribers in batch","user":{"login":"hexgnu","id":138510,"avatar_url":"https://avatars.githubusercontent.com/u/138510?v=3","gravatar_id":"","url":"https://api.github.com/users/hexgnu","html_url":"https://github.com/hexgnu","followers_url":"https://api.github.com/users/hexgnu/followers","following_url":"https://api.github.com/users/hexgnu/following{/other_user}","gists_url":"https://api.github.com/users/hexgnu/gists{/gist_id}","starred_url":"https://api.github.com/users/hexgnu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hexgnu/subscriptions","organizations_url":"https://api.github.com/users/hexgnu/orgs","repos_url":"https://api.github.com/users/hexgnu/repos","events_url":"https://api.github.com/users/hexgnu/events{/privacy}","received_events_url":"https://api.github.com/users/hexgnu/received_events","type":"User","site_admin":false},"body":"What\r\n=====\r\n\r\nThis will allow users to post new subscribers to their db. \r\n\r\nThe base case is\r\n\r\n`http -j POST :3000/subscribers address=flap@flap.com`\r\n\r\nBut then there's other cases that need to be taken into consideration. These are handled through a json-schema middleware.\r\n\r\n`http -j POST :3000/subscribers` should show an error\r\n`http -j POST :3000/subscribers flap=blap` should show a useful error message to the end user.\r\n\r\nI'm using JSend responses and I think we should adopt that for the app. it's simple http://labs.omniti.com/labs/jsend\r\n\r\nHow to test\r\n==========\r\n\r\nTODO\r\n=====\r\n- [ ] Make JSON Schema for array so we can post [{\"address\": \"flap@flap.com\"}, {\"address\": \"map@map.com\"}]\r\n- [ ] Testing throughout. Would like a full integration test testing JSON posting etc, then also unit tests around the idempotent functions like create-subscriber! etc.\r\n- [x] Code organization seems off to me. jsend responses should probably be put somewhere.","created_at":"2015-04-13T19:45:40Z","updated_at":"2015-04-14T16:49:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13edb5939507ab57cf47430f946724df42767fb1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1/commits","review_comments_url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1/comments","review_comment_url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/comments{/number}","comments_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/1/comments","statuses_url":"https://api.github.com/repos/madetomeasure/madetomeasure/statuses/a094b33fb0a73edd2b41fe3e29604623179e3b58","head":{"label":"madetomeasure:create_subscribers_in_batch","ref":"create_subscribers_in_batch","sha":"a094b33fb0a73edd2b41fe3e29604623179e3b58","user":{"login":"madetomeasure","id":10717155,"avatar_url":"https://avatars.githubusercontent.com/u/10717155?v=3","gravatar_id":"","url":"https://api.github.com/users/madetomeasure","html_url":"https://github.com/madetomeasure","followers_url":"https://api.github.com/users/madetomeasure/followers","following_url":"https://api.github.com/users/madetomeasure/following{/other_user}","gists_url":"https://api.github.com/users/madetomeasure/gists{/gist_id}","starred_url":"https://api.github.com/users/madetomeasure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madetomeasure/subscriptions","organizations_url":"https://api.github.com/users/madetomeasure/orgs","repos_url":"https://api.github.com/users/madetomeasure/repos","events_url":"https://api.github.com/users/madetomeasure/events{/privacy}","received_events_url":"https://api.github.com/users/madetomeasure/received_events","type":"Organization","site_admin":false},"repo":{"id":33564848,"name":"madetomeasure","full_name":"madetomeasure/madetomeasure","owner":{"login":"madetomeasure","id":10717155,"avatar_url":"https://avatars.githubusercontent.com/u/10717155?v=3","gravatar_id":"","url":"https://api.github.com/users/madetomeasure","html_url":"https://github.com/madetomeasure","followers_url":"https://api.github.com/users/madetomeasure/followers","following_url":"https://api.github.com/users/madetomeasure/following{/other_user}","gists_url":"https://api.github.com/users/madetomeasure/gists{/gist_id}","starred_url":"https://api.github.com/users/madetomeasure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madetomeasure/subscriptions","organizations_url":"https://api.github.com/users/madetomeasure/orgs","repos_url":"https://api.github.com/users/madetomeasure/repos","events_url":"https://api.github.com/users/madetomeasure/events{/privacy}","received_events_url":"https://api.github.com/users/madetomeasure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/madetomeasure/madetomeasure","description":"The Frontend","fork":false,"url":"https://api.github.com/repos/madetomeasure/madetomeasure","forks_url":"https://api.github.com/repos/madetomeasure/madetomeasure/forks","keys_url":"https://api.github.com/repos/madetomeasure/madetomeasure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/madetomeasure/madetomeasure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/madetomeasure/madetomeasure/teams","hooks_url":"https://api.github.com/repos/madetomeasure/madetomeasure/hooks","issue_events_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/events{/number}","events_url":"https://api.github.com/repos/madetomeasure/madetomeasure/events","assignees_url":"https://api.github.com/repos/madetomeasure/madetomeasure/assignees{/user}","branches_url":"https://api.github.com/repos/madetomeasure/madetomeasure/branches{/branch}","tags_url":"https://api.github.com/repos/madetomeasure/madetomeasure/tags","blobs_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/refs{/sha}","trees_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/madetomeasure/madetomeasure/statuses/{sha}","languages_url":"https://api.github.com/repos/madetomeasure/madetomeasure/languages","stargazers_url":"https://api.github.com/repos/madetomeasure/madetomeasure/stargazers","contributors_url":"https://api.github.com/repos/madetomeasure/madetomeasure/contributors","subscribers_url":"https://api.github.com/repos/madetomeasure/madetomeasure/subscribers","subscription_url":"https://api.github.com/repos/madetomeasure/madetomeasure/subscription","commits_url":"https://api.github.com/repos/madetomeasure/madetomeasure/commits{/sha}","git_commits_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/commits{/sha}","comments_url":"https://api.github.com/repos/madetomeasure/madetomeasure/comments{/number}","issue_comment_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/comments{/number}","contents_url":"https://api.github.com/repos/madetomeasure/madetomeasure/contents/{+path}","compare_url":"https://api.github.com/repos/madetomeasure/madetomeasure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/madetomeasure/madetomeasure/merges","archive_url":"https://api.github.com/repos/madetomeasure/madetomeasure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/madetomeasure/madetomeasure/downloads","issues_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues{/number}","pulls_url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls{/number}","milestones_url":"https://api.github.com/repos/madetomeasure/madetomeasure/milestones{/number}","notifications_url":"https://api.github.com/repos/madetomeasure/madetomeasure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/madetomeasure/madetomeasure/labels{/name}","releases_url":"https://api.github.com/repos/madetomeasure/madetomeasure/releases{/id}","created_at":"2015-04-07T19:52:09Z","updated_at":"2015-04-09T22:07:03Z","pushed_at":"2015-04-14T16:39:05Z","git_url":"git://github.com/madetomeasure/madetomeasure.git","ssh_url":"git@github.com:madetomeasure/madetomeasure.git","clone_url":"https://github.com/madetomeasure/madetomeasure.git","svn_url":"https://github.com/madetomeasure/madetomeasure","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"madetomeasure:master","ref":"master","sha":"db36dc8e8e856a62ff3f42a6bc9a2090c17a6e15","user":{"login":"madetomeasure","id":10717155,"avatar_url":"https://avatars.githubusercontent.com/u/10717155?v=3","gravatar_id":"","url":"https://api.github.com/users/madetomeasure","html_url":"https://github.com/madetomeasure","followers_url":"https://api.github.com/users/madetomeasure/followers","following_url":"https://api.github.com/users/madetomeasure/following{/other_user}","gists_url":"https://api.github.com/users/madetomeasure/gists{/gist_id}","starred_url":"https://api.github.com/users/madetomeasure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madetomeasure/subscriptions","organizations_url":"https://api.github.com/users/madetomeasure/orgs","repos_url":"https://api.github.com/users/madetomeasure/repos","events_url":"https://api.github.com/users/madetomeasure/events{/privacy}","received_events_url":"https://api.github.com/users/madetomeasure/received_events","type":"Organization","site_admin":false},"repo":{"id":33564848,"name":"madetomeasure","full_name":"madetomeasure/madetomeasure","owner":{"login":"madetomeasure","id":10717155,"avatar_url":"https://avatars.githubusercontent.com/u/10717155?v=3","gravatar_id":"","url":"https://api.github.com/users/madetomeasure","html_url":"https://github.com/madetomeasure","followers_url":"https://api.github.com/users/madetomeasure/followers","following_url":"https://api.github.com/users/madetomeasure/following{/other_user}","gists_url":"https://api.github.com/users/madetomeasure/gists{/gist_id}","starred_url":"https://api.github.com/users/madetomeasure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madetomeasure/subscriptions","organizations_url":"https://api.github.com/users/madetomeasure/orgs","repos_url":"https://api.github.com/users/madetomeasure/repos","events_url":"https://api.github.com/users/madetomeasure/events{/privacy}","received_events_url":"https://api.github.com/users/madetomeasure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/madetomeasure/madetomeasure","description":"The Frontend","fork":false,"url":"https://api.github.com/repos/madetomeasure/madetomeasure","forks_url":"https://api.github.com/repos/madetomeasure/madetomeasure/forks","keys_url":"https://api.github.com/repos/madetomeasure/madetomeasure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/madetomeasure/madetomeasure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/madetomeasure/madetomeasure/teams","hooks_url":"https://api.github.com/repos/madetomeasure/madetomeasure/hooks","issue_events_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/events{/number}","events_url":"https://api.github.com/repos/madetomeasure/madetomeasure/events","assignees_url":"https://api.github.com/repos/madetomeasure/madetomeasure/assignees{/user}","branches_url":"https://api.github.com/repos/madetomeasure/madetomeasure/branches{/branch}","tags_url":"https://api.github.com/repos/madetomeasure/madetomeasure/tags","blobs_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/refs{/sha}","trees_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/madetomeasure/madetomeasure/statuses/{sha}","languages_url":"https://api.github.com/repos/madetomeasure/madetomeasure/languages","stargazers_url":"https://api.github.com/repos/madetomeasure/madetomeasure/stargazers","contributors_url":"https://api.github.com/repos/madetomeasure/madetomeasure/contributors","subscribers_url":"https://api.github.com/repos/madetomeasure/madetomeasure/subscribers","subscription_url":"https://api.github.com/repos/madetomeasure/madetomeasure/subscription","commits_url":"https://api.github.com/repos/madetomeasure/madetomeasure/commits{/sha}","git_commits_url":"https://api.github.com/repos/madetomeasure/madetomeasure/git/commits{/sha}","comments_url":"https://api.github.com/repos/madetomeasure/madetomeasure/comments{/number}","issue_comment_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/comments{/number}","contents_url":"https://api.github.com/repos/madetomeasure/madetomeasure/contents/{+path}","compare_url":"https://api.github.com/repos/madetomeasure/madetomeasure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/madetomeasure/madetomeasure/merges","archive_url":"https://api.github.com/repos/madetomeasure/madetomeasure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/madetomeasure/madetomeasure/downloads","issues_url":"https://api.github.com/repos/madetomeasure/madetomeasure/issues{/number}","pulls_url":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls{/number}","milestones_url":"https://api.github.com/repos/madetomeasure/madetomeasure/milestones{/number}","notifications_url":"https://api.github.com/repos/madetomeasure/madetomeasure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/madetomeasure/madetomeasure/labels{/name}","releases_url":"https://api.github.com/repos/madetomeasure/madetomeasure/releases{/id}","created_at":"2015-04-07T19:52:09Z","updated_at":"2015-04-09T22:07:03Z","pushed_at":"2015-04-14T16:39:05Z","git_url":"git://github.com/madetomeasure/madetomeasure.git","ssh_url":"git@github.com:madetomeasure/madetomeasure.git","clone_url":"https://github.com/madetomeasure/madetomeasure.git","svn_url":"https://github.com/madetomeasure/madetomeasure","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1"},"html":{"href":"https://github.com/madetomeasure/madetomeasure/pull/1"},"issue":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/1"},"comments":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/madetomeasure/madetomeasure/statuses/a094b33fb0a73edd2b41fe3e29604623179e3b58"}}}}