{"action":"opened","number":94,"pull_request":{"url":"https://api.github.com/repos/gardners/surveysystem/pulls/94","id":242175794,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQyMTc1Nzk0","html_url":"https://github.com/gardners/surveysystem/pull/94","diff_url":"https://github.com/gardners/surveysystem/pull/94.diff","patch_url":"https://github.com/gardners/surveysystem/pull/94.patch","issue_url":"https://api.github.com/repos/gardners/surveysystem/issues/94","number":94,"state":"open","locked":false,"title":"Add backend fields: unit","user":{"login":"RoboSparrow","id":4016086,"node_id":"MDQ6VXNlcjQwMTYwODY=","avatar_url":"https://avatars0.githubusercontent.com/u/4016086?v=4","gravatar_id":"","url":"https://api.github.com/users/RoboSparrow","html_url":"https://github.com/RoboSparrow","followers_url":"https://api.github.com/users/RoboSparrow/followers","following_url":"https://api.github.com/users/RoboSparrow/following{/other_user}","gists_url":"https://api.github.com/users/RoboSparrow/gists{/gist_id}","starred_url":"https://api.github.com/users/RoboSparrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoboSparrow/subscriptions","organizations_url":"https://api.github.com/users/RoboSparrow/orgs","repos_url":"https://api.github.com/users/RoboSparrow/repos","events_url":"https://api.github.com/users/RoboSparrow/events{/privacy}","received_events_url":"https://api.github.com/users/RoboSparrow/received_events","type":"User","site_admin":false},"body":"see #72 \r\n# `unit` field\r\n* adds **unit** field (string).  Since there is no logic  in the backend to this field I refrained from eunums\r\n\r\n| field     | in question | in answer | description |\r\n| ---         | ---         | ---       | ---         |\r\n| unit      | x           | x         | defines, displays and stores value unit |\r\n\r\nFormats:\r\n\r\n* question: `question1:How many days are in February?:How many days are in February?:INT:0::-1:-1:0:0::days`\r\n* next_question: `{\"next_questions\": [{\"id\": \"question1\", \"name\": \"question1\", \"title\": \"How many days are in February?\", \"title_text\": \"How many days are in February?\", \"type\": \"INT\", \"unit\": \"days\"}]}`\r\n* answer: `question1::28:0:0:0:0:0:0:days`\r\n\r\nsee [field_unit.test](https://github.com/gardners/surveysystem/blob/421675cb15b3038535390c58dfcfb30930fb4044/backend/tests/field_unit.test)\r\n\r\nApologies, this PR is polluted by some frontend commits and some automatic tabs-for-spaces replacement by my editor\r\n\r\n@gardners Still learning.. Here is the workflow I followed for adding a new field. Please check and give feedback if I forgot something so we can document this\r\n\r\n### question\r\n\r\n1. **includes/survey.h**: \r\n    - add field to `struct question`\r\n2. **src/serialisers.c** \r\n    - add field to `serialise_question()`\r\n    - add field to `deserialise_question()`\r\n    - add field to `compare_questions()`\r\n3. **src/sessions.c**\r\n    - `free_question()` add `freez(<field>)`\r\n4. **src/fcgimain.c**\r\n    - `fcgi_nextquestion()` add `kjson_put_*` declaration for field\r\n\r\n### answer (only if field is stored in answer)\r\n\r\n1. **includes/survey.h**: \r\n    - add field to `struct answer`\r\n2. **src/serialisers.c** \r\n    - add field to `serialise_answer()`\r\n    - add field to `deserialise_answer()`\r\n    - add field to `compare_answers()`\r\n**???** Note: in my understanding there is no need to add the field to `free_answer()`?\r\n\r\n\r\n### debug\r\n\r\n* **src/serialisers.c**\r\n int dump_question\r\n\r\n### tests\r\n\r\n1. add field to existing tests\r\n    - payload\r\n    - next_question\r\n    - answer check\r\n\r\n1. create field_<my field>.test test\r\n    - payload\r\n    - next_question\r\n    - answer check","created_at":"2019-01-04T05:03:07Z","updated_at":"2019-01-04T05:03:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/gardners/surveysystem/pulls/94/commits","review_comments_url":"https://api.github.com/repos/gardners/surveysystem/pulls/94/comments","review_comment_url":"https://api.github.com/repos/gardners/surveysystem/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gardners/surveysystem/issues/94/comments","statuses_url":"https://api.github.com/repos/gardners/surveysystem/statuses/421675cb15b3038535390c58dfcfb30930fb4044","head":{"label":"gardners:fields","ref":"fields","sha":"421675cb15b3038535390c58dfcfb30930fb4044","user":{"login":"gardners","id":665423,"node_id":"MDQ6VXNlcjY2NTQyMw==","avatar_url":"https://avatars2.githubusercontent.com/u/665423?v=4","gravatar_id":"","url":"https://api.github.com/users/gardners","html_url":"https://github.com/gardners","followers_url":"https://api.github.com/users/gardners/followers","following_url":"https://api.github.com/users/gardners/following{/other_user}","gists_url":"https://api.github.com/users/gardners/gists{/gist_id}","starred_url":"https://api.github.com/users/gardners/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gardners/subscriptions","organizations_url":"https://api.github.com/users/gardners/orgs","repos_url":"https://api.github.com/users/gardners/repos","events_url":"https://api.github.com/users/gardners/events{/privacy}","received_events_url":"https://api.github.com/users/gardners/received_events","type":"User","site_admin":false},"repo":{"id":142926685,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI5MjY2ODU=","name":"surveysystem","full_name":"gardners/surveysystem","private":false,"owner":{"login":"gardners","id":665423,"node_id":"MDQ6VXNlcjY2NTQyMw==","avatar_url":"https://avatars2.githubusercontent.com/u/665423?v=4","gravatar_id":"","url":"https://api.github.com/users/gardners","html_url":"https://github.com/gardners","followers_url":"https://api.github.com/users/gardners/followers","following_url":"https://api.github.com/users/gardners/following{/other_user}","gists_url":"https://api.github.com/users/gardners/gists{/gist_id}","starred_url":"https://api.github.com/users/gardners/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gardners/subscriptions","organizations_url":"https://api.github.com/users/gardners/orgs","repos_url":"https://api.github.com/users/gardners/repos","events_url":"https://api.github.com/users/gardners/events{/privacy}","received_events_url":"https://api.github.com/users/gardners/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gardners/surveysystem","description":"System for on-line and off-grid survey preparation and submissions","fork":false,"url":"https://api.github.com/repos/gardners/surveysystem","forks_url":"https://api.github.com/repos/gardners/surveysystem/forks","keys_url":"https://api.github.com/repos/gardners/surveysystem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gardners/surveysystem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gardners/surveysystem/teams","hooks_url":"https://api.github.com/repos/gardners/surveysystem/hooks","issue_events_url":"https://api.github.com/repos/gardners/surveysystem/issues/events{/number}","events_url":"https://api.github.com/repos/gardners/surveysystem/events","assignees_url":"https://api.github.com/repos/gardners/surveysystem/assignees{/user}","branches_url":"https://api.github.com/repos/gardners/surveysystem/branches{/branch}","tags_url":"https://api.github.com/repos/gardners/surveysystem/tags","blobs_url":"https://api.github.com/repos/gardners/surveysystem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gardners/surveysystem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gardners/surveysystem/git/refs{/sha}","trees_url":"https://api.github.com/repos/gardners/surveysystem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gardners/surveysystem/statuses/{sha}","languages_url":"https://api.github.com/repos/gardners/surveysystem/languages","stargazers_url":"https://api.github.com/repos/gardners/surveysystem/stargazers","contributors_url":"https://api.github.com/repos/gardners/surveysystem/contributors","subscribers_url":"https://api.github.com/repos/gardners/surveysystem/subscribers","subscription_url":"https://api.github.com/repos/gardners/surveysystem/subscription","commits_url":"https://api.github.com/repos/gardners/surveysystem/commits{/sha}","git_commits_url":"https://api.github.com/repos/gardners/surveysystem/git/commits{/sha}","comments_url":"https://api.github.com/repos/gardners/surveysystem/comments{/number}","issue_comment_url":"https://api.github.com/repos/gardners/surveysystem/issues/comments{/number}","contents_url":"https://api.github.com/repos/gardners/surveysystem/contents/{+path}","compare_url":"https://api.github.com/repos/gardners/surveysystem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gardners/surveysystem/merges","archive_url":"https://api.github.com/repos/gardners/surveysystem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gardners/surveysystem/downloads","issues_url":"https://api.github.com/repos/gardners/surveysystem/issues{/number}","pulls_url":"https://api.github.com/repos/gardners/surveysystem/pulls{/number}","milestones_url":"https://api.github.com/repos/gardners/surveysystem/milestones{/number}","notifications_url":"https://api.github.com/repos/gardners/surveysystem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gardners/surveysystem/labels{/name}","releases_url":"https://api.github.com/repos/gardners/surveysystem/releases{/id}","deployments_url":"https://api.github.com/repos/gardners/surveysystem/deployments","created_at":"2018-07-30T20:48:47Z","updated_at":"2019-01-02T00:51:13Z","pushed_at":"2019-01-04T03:59:29Z","git_url":"git://github.com/gardners/surveysystem.git","ssh_url":"git@github.com:gardners/surveysystem.git","clone_url":"https://github.com/gardners/surveysystem.git","svn_url":"https://github.com/gardners/surveysystem","homepage":null,"size":33276,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":22,"license":null,"forks":0,"open_issues":22,"watchers":1,"default_branch":"master"}},"base":{"label":"gardners:master","ref":"master","sha":"301a1d875e3bf878a480d82e3ebbdf3a35334e01","user":{"login":"gardners","id":665423,"node_id":"MDQ6VXNlcjY2NTQyMw==","avatar_url":"https://avatars2.githubusercontent.com/u/665423?v=4","gravatar_id":"","url":"https://api.github.com/users/gardners","html_url":"https://github.com/gardners","followers_url":"https://api.github.com/users/gardners/followers","following_url":"https://api.github.com/users/gardners/following{/other_user}","gists_url":"https://api.github.com/users/gardners/gists{/gist_id}","starred_url":"https://api.github.com/users/gardners/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gardners/subscriptions","organizations_url":"https://api.github.com/users/gardners/orgs","repos_url":"https://api.github.com/users/gardners/repos","events_url":"https://api.github.com/users/gardners/events{/privacy}","received_events_url":"https://api.github.com/users/gardners/received_events","type":"User","site_admin":false},"repo":{"id":142926685,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI5MjY2ODU=","name":"surveysystem","full_name":"gardners/surveysystem","private":false,"owner":{"login":"gardners","id":665423,"node_id":"MDQ6VXNlcjY2NTQyMw==","avatar_url":"https://avatars2.githubusercontent.com/u/665423?v=4","gravatar_id":"","url":"https://api.github.com/users/gardners","html_url":"https://github.com/gardners","followers_url":"https://api.github.com/users/gardners/followers","following_url":"https://api.github.com/users/gardners/following{/other_user}","gists_url":"https://api.github.com/users/gardners/gists{/gist_id}","starred_url":"https://api.github.com/users/gardners/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gardners/subscriptions","organizations_url":"https://api.github.com/users/gardners/orgs","repos_url":"https://api.github.com/users/gardners/repos","events_url":"https://api.github.com/users/gardners/events{/privacy}","received_events_url":"https://api.github.com/users/gardners/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gardners/surveysystem","description":"System for on-line and off-grid survey preparation and submissions","fork":false,"url":"https://api.github.com/repos/gardners/surveysystem","forks_url":"https://api.github.com/repos/gardners/surveysystem/forks","keys_url":"https://api.github.com/repos/gardners/surveysystem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gardners/surveysystem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gardners/surveysystem/teams","hooks_url":"https://api.github.com/repos/gardners/surveysystem/hooks","issue_events_url":"https://api.github.com/repos/gardners/surveysystem/issues/events{/number}","events_url":"https://api.github.com/repos/gardners/surveysystem/events","assignees_url":"https://api.github.com/repos/gardners/surveysystem/assignees{/user}","branches_url":"https://api.github.com/repos/gardners/surveysystem/branches{/branch}","tags_url":"https://api.github.com/repos/gardners/surveysystem/tags","blobs_url":"https://api.github.com/repos/gardners/surveysystem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gardners/surveysystem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gardners/surveysystem/git/refs{/sha}","trees_url":"https://api.github.com/repos/gardners/surveysystem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gardners/surveysystem/statuses/{sha}","languages_url":"https://api.github.com/repos/gardners/surveysystem/languages","stargazers_url":"https://api.github.com/repos/gardners/surveysystem/stargazers","contributors_url":"https://api.github.com/repos/gardners/surveysystem/contributors","subscribers_url":"https://api.github.com/repos/gardners/surveysystem/subscribers","subscription_url":"https://api.github.com/repos/gardners/surveysystem/subscription","commits_url":"https://api.github.com/repos/gardners/surveysystem/commits{/sha}","git_commits_url":"https://api.github.com/repos/gardners/surveysystem/git/commits{/sha}","comments_url":"https://api.github.com/repos/gardners/surveysystem/comments{/number}","issue_comment_url":"https://api.github.com/repos/gardners/surveysystem/issues/comments{/number}","contents_url":"https://api.github.com/repos/gardners/surveysystem/contents/{+path}","compare_url":"https://api.github.com/repos/gardners/surveysystem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gardners/surveysystem/merges","archive_url":"https://api.github.com/repos/gardners/surveysystem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gardners/surveysystem/downloads","issues_url":"https://api.github.com/repos/gardners/surveysystem/issues{/number}","pulls_url":"https://api.github.com/repos/gardners/surveysystem/pulls{/number}","milestones_url":"https://api.github.com/repos/gardners/surveysystem/milestones{/number}","notifications_url":"https://api.github.com/repos/gardners/surveysystem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gardners/surveysystem/labels{/name}","releases_url":"https://api.github.com/repos/gardners/surveysystem/releases{/id}","deployments_url":"https://api.github.com/repos/gardners/surveysystem/deployments","created_at":"2018-07-30T20:48:47Z","updated_at":"2019-01-02T00:51:13Z","pushed_at":"2019-01-04T03:59:29Z","git_url":"git://github.com/gardners/surveysystem.git","ssh_url":"git@github.com:gardners/surveysystem.git","clone_url":"https://github.com/gardners/surveysystem.git","svn_url":"https://github.com/gardners/surveysystem","homepage":null,"size":33276,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":22,"license":null,"forks":0,"open_issues":22,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gardners/surveysystem/pulls/94"},"html":{"href":"https://github.com/gardners/surveysystem/pull/94"},"issue":{"href":"https://api.github.com/repos/gardners/surveysystem/issues/94"},"comments":{"href":"https://api.github.com/repos/gardners/surveysystem/issues/94/comments"},"review_comments":{"href":"https://api.github.com/repos/gardners/surveysystem/pulls/94/comments"},"review_comment":{"href":"https://api.github.com/repos/gardners/surveysystem/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gardners/surveysystem/pulls/94/commits"},"statuses":{"href":"https://api.github.com/repos/gardners/surveysystem/statuses/421675cb15b3038535390c58dfcfb30930fb4044"}},"author_association":"COLLABORATOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":12,"additions":857,"deletions":392,"changed_files":44}}
{"actor":{"display_login":"RoboSparrow"}}