{"action":"created","comment":{"url":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/comments/114147870","pull_request_review_id":35590947,"id":114147870,"diff_hunk":"@@ -32,56 +32,65 @@\n #'data_20 = scan_data(stations, -20)\n #'\n #'#40 inch\n-#'data_20 = scan_data(stations, -40)\n+#'data_40 = scan_data(stations, -40)\n #'}\n #'@export\n scan_data = function(stationTriplets, depth, start=Sys.Date()-as.difftime(1, units='days'), end=Sys.Date()){\n \t\n+  returns = data.frame()\n+  stationChunks = split(stationTriplets, ceiling(seq_along(stationTriplets)/5))\n+  \n+  for(i in 1:length(stationChunks)){\n+  \n+\t  cmd = xmlNode(\"q0:getHourlyData\")\n \t\n-\tcmd = xmlNode(\"tns:getHourlyData\", namespaceDefinitions=c(\"tns\"=\"http://wcc.sc.egov.usda.gov/awdbWebService\"))\n+\t  stationNodes = lapply(stationChunks[[i]], xmlNode, name=\"stationTriplets\")\n+    cmd = addChildren(cmd, kids=stationNodes)\n \t\n-\tstationNodes = lapply(stationTriplets, xmlNode, name=\"stationTriplets\")\n-  cmd = addChildren(cmd, kids=stationNodes)\n-\t\n-\tcmd = addChildren(cmd, kids=list(\n+\t  cmd = addChildren(cmd, kids=list(\n \t\txmlNode(\"ordinal\", 1),\n \t\txmlNode(\"beginDate\", as.character(start)),\n \t\txmlNode(\"endDate\", as.character(end))))\n \t\n-\t#newXMLNode(\"getFlags\", \"true\", parent=cmd)\n-\t#newXMLNode(\"alwaysReturnDailyFeb29\", \"true\", parent=cmd)\n-\t#newXMLNode(\"duration\", \"DAILY\", parent=cmd)\n-\thd = xmlNode(\"heightDepth\", \n-\t\txmlNode(\"unitCd\",'in'),\n-\t\txmlNode(\"value\", depth))\n-\t\n-\tcmd = addChildren(cmd, kids=list(\n-\t\thd, \n-\t\txmlNode(\"elementCd\", \"SMS\")\n-\t\t))\n-\t\n-\tbody = xmlNode(\"soap:Body\", cmd)\n-\t\n-\troot = xmlNode(\"soap:Envelope\", namespaceDefinitions=c(\"soap\"=\"http://schemas.xmlsoap.org/soap/envelope/\", \"xsd\"=\"http://www.w3.org/2001/XMLSchema\"), body)\n-\t\n-\tout = POST(service_url, content_type(\"text/soap_xml; charset-utf-8\"), body=toString.XMLNode(root))\n-\t#values = xpathSApply(content(out), '//values', xmlValue)\n-\t\n-\tparse_vals = function(x){\n-\t\tstation = xpathSApply(x, 'stationTriplet', xmlValue)\n-\t\tdatetime = xpathSApply(x, 'values/dateTime', xmlValue)\n-\t\tflag = xpathSApply(x, 'values/flag', xmlValue)\n-\t\tvalue = xpathSApply(x, 'values/value', xmlValue, trim=TRUE)\n-\t\t\n-\t\treturn(data.frame(station, datetime, flag, value, stringsAsFactors = FALSE))\n-\t}\n-\t\n-\treturns = xpathApply(content(out), '/*/*/*/return[values]', fun=parse_vals)\n-\t\n-\tall_out = do.call(rbind, returns)\n-\tall_out$depth_cm = floor(abs(depth*2.54)) #convert to cm and round this one because that's what TX group is doing\n-\tall_out$value = as.numeric(all_out$value)\n-\tall_out$flag = NULL #drop flag for now, not using it, no other service has them\n+  \t#newXMLNode(\"getFlags\", \"true\", parent=cmd)\n+  \t#newXMLNode(\"alwaysReturnDailyFeb29\", \"true\", parent=cmd)\n+  \t#newXMLNode(\"duration\", \"DAILY\", parent=cmd)\n+  \thd = xmlNode(\"heightDepth\", \n+  \t\txmlNode(\"unitCd\",'in'),\n+  \t\txmlNode(\"value\", depth))\n+  \t\n+  \tcmd = addChildren(cmd, kids=list(\n+  \t\thd, \n+  \t\txmlNode(\"elementCd\", \"SMS\")\n+  \t\t))\n+  \t\n+  \tbody = xmlNode(\"SOAP-ENV:Body\", cmd)\n+  \t\n+  \troot = xmlNode(\"SOAP-ENV:Envelope\", namespaceDefinitions=c(\"SOAP-ENV\"=\"http://schemas.xmlsoap.org/soap/envelope/\", \"q0\"=\"http://www.wcc.nrcs.usda.gov/ns/awdbWebService\", \"xsd\"=\"http://www.w3.org/2001/XMLSchema\", \"xsi\"=\"http://www.w3.org/2001/XMLSchema-instance\"), body)\n+  \t\n+  \tout = POST(service_url, content_type(\"text/soap_xml; charset-utf-8\"), body=toString.XMLNode(root))\n+  \t#values = xpathSApply(content(out), '//values', xmlValue)\n+  \t\n+  \tparse_vals = function(x){\n+  \t  station = xpathSApply(x, 'stationTriplet', xmlValue)\n+  \t  datetime = xpathSApply(x, 'values/dateTime', xmlValue)\n+  \t  flag = xpathSApply(x, 'values/flag', xmlValue)\n+  \t  value = xpathSApply(x, 'values/value', xmlValue, trim=TRUE)\n+  \t\t\n+  \t\treturn(data.frame(station, datetime, flag, value, stringsAsFactors = FALSE))\n+  \t  \n+  \t  \n+  \t}\n+    vals = xpathApply(content(out), '/*/*/*/return[values]', fun=parse_vals)\n+  \tvals = do.call(rbind, vals)\n+  \treturns = rbind(returns, vals)","path":"R/scan_data.R","position":95,"original_position":95,"commit_id":"800862b43f8c3a2520fd229959df0c85e457ad2a","original_commit_id":"800862b43f8c3a2520fd229959df0c85e457ad2a","user":{"login":"mhines-usgs","id":6920344,"avatar_url":"https://avatars0.githubusercontent.com/u/6920344?v=3","gravatar_id":"","url":"https://api.github.com/users/mhines-usgs","html_url":"https://github.com/mhines-usgs","followers_url":"https://api.github.com/users/mhines-usgs/followers","following_url":"https://api.github.com/users/mhines-usgs/following{/other_user}","gists_url":"https://api.github.com/users/mhines-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/mhines-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhines-usgs/subscriptions","organizations_url":"https://api.github.com/users/mhines-usgs/orgs","repos_url":"https://api.github.com/users/mhines-usgs/repos","events_url":"https://api.github.com/users/mhines-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/mhines-usgs/received_events","type":"User","site_admin":false},"body":"stash vals into returns and keep looping","created_at":"2017-05-01T16:13:49Z","updated_at":"2017-05-01T16:13:49Z","html_url":"https://github.com/USGS-R/soilmoisturetools/pull/46#discussion_r114147870","pull_request_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/comments/114147870"},"html":{"href":"https://github.com/USGS-R/soilmoisturetools/pull/46#discussion_r114147870"},"pull_request":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46","id":118035340,"html_url":"https://github.com/USGS-R/soilmoisturetools/pull/46","diff_url":"https://github.com/USGS-R/soilmoisturetools/pull/46.diff","patch_url":"https://github.com/USGS-R/soilmoisturetools/pull/46.patch","issue_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/issues/46","number":46,"state":"open","locked":false,"title":"WIP for NSMN-68","user":{"login":"mhines-usgs","id":6920344,"avatar_url":"https://avatars0.githubusercontent.com/u/6920344?v=3","gravatar_id":"","url":"https://api.github.com/users/mhines-usgs","html_url":"https://github.com/mhines-usgs","followers_url":"https://api.github.com/users/mhines-usgs/followers","following_url":"https://api.github.com/users/mhines-usgs/following{/other_user}","gists_url":"https://api.github.com/users/mhines-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/mhines-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhines-usgs/subscriptions","organizations_url":"https://api.github.com/users/mhines-usgs/orgs","repos_url":"https://api.github.com/users/mhines-usgs/repos","events_url":"https://api.github.com/users/mhines-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/mhines-usgs/received_events","type":"User","site_admin":false},"body":"Updating SCAN work to reflect updated API","created_at":"2017-04-27T21:22:46Z","updated_at":"2017-05-01T16:13:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f4c8e7cbf850be22c7477d31199d2fe1aa5c694","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46/commits","review_comments_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46/comments","review_comment_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/issues/46/comments","statuses_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/statuses/800862b43f8c3a2520fd229959df0c85e457ad2a","head":{"label":"mhines-usgs:master","ref":"master","sha":"800862b43f8c3a2520fd229959df0c85e457ad2a","user":{"login":"mhines-usgs","id":6920344,"avatar_url":"https://avatars0.githubusercontent.com/u/6920344?v=3","gravatar_id":"","url":"https://api.github.com/users/mhines-usgs","html_url":"https://github.com/mhines-usgs","followers_url":"https://api.github.com/users/mhines-usgs/followers","following_url":"https://api.github.com/users/mhines-usgs/following{/other_user}","gists_url":"https://api.github.com/users/mhines-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/mhines-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhines-usgs/subscriptions","organizations_url":"https://api.github.com/users/mhines-usgs/orgs","repos_url":"https://api.github.com/users/mhines-usgs/repos","events_url":"https://api.github.com/users/mhines-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/mhines-usgs/received_events","type":"User","site_admin":false},"repo":{"id":76681987,"name":"soilmoisturetools","full_name":"mhines-usgs/soilmoisturetools","owner":{"login":"mhines-usgs","id":6920344,"avatar_url":"https://avatars0.githubusercontent.com/u/6920344?v=3","gravatar_id":"","url":"https://api.github.com/users/mhines-usgs","html_url":"https://github.com/mhines-usgs","followers_url":"https://api.github.com/users/mhines-usgs/followers","following_url":"https://api.github.com/users/mhines-usgs/following{/other_user}","gists_url":"https://api.github.com/users/mhines-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/mhines-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhines-usgs/subscriptions","organizations_url":"https://api.github.com/users/mhines-usgs/orgs","repos_url":"https://api.github.com/users/mhines-usgs/repos","events_url":"https://api.github.com/users/mhines-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/mhines-usgs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mhines-usgs/soilmoisturetools","description":"Tools for soil moisture data retrieval and visualization","fork":true,"url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools","forks_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/forks","keys_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/teams","hooks_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/hooks","issue_events_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/issues/events{/number}","events_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/events","assignees_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/assignees{/user}","branches_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/branches{/branch}","tags_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/tags","blobs_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/git/refs{/sha}","trees_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/statuses/{sha}","languages_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/languages","stargazers_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/stargazers","contributors_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/contributors","subscribers_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/subscribers","subscription_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/subscription","commits_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/commits{/sha}","git_commits_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/git/commits{/sha}","comments_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/comments{/number}","issue_comment_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/issues/comments{/number}","contents_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/contents/{+path}","compare_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/merges","archive_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/downloads","issues_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/issues{/number}","pulls_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/pulls{/number}","milestones_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/milestones{/number}","notifications_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/labels{/name}","releases_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/releases{/id}","deployments_url":"https://api.github.com/repos/mhines-usgs/soilmoisturetools/deployments","created_at":"2016-12-16T20:02:31Z","updated_at":"2016-12-16T20:02:33Z","pushed_at":"2017-05-01T16:09:43Z","git_url":"git://github.com/mhines-usgs/soilmoisturetools.git","ssh_url":"git@github.com:mhines-usgs/soilmoisturetools.git","clone_url":"https://github.com/mhines-usgs/soilmoisturetools.git","svn_url":"https://github.com/mhines-usgs/soilmoisturetools","homepage":null,"size":2266,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"USGS-R:master","ref":"master","sha":"d7ed537a35a65a7932e709a3a60c94208a534bad","user":{"login":"USGS-R","id":3188813,"avatar_url":"https://avatars0.githubusercontent.com/u/3188813?v=3","gravatar_id":"","url":"https://api.github.com/users/USGS-R","html_url":"https://github.com/USGS-R","followers_url":"https://api.github.com/users/USGS-R/followers","following_url":"https://api.github.com/users/USGS-R/following{/other_user}","gists_url":"https://api.github.com/users/USGS-R/gists{/gist_id}","starred_url":"https://api.github.com/users/USGS-R/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/USGS-R/subscriptions","organizations_url":"https://api.github.com/users/USGS-R/orgs","repos_url":"https://api.github.com/users/USGS-R/repos","events_url":"https://api.github.com/users/USGS-R/events{/privacy}","received_events_url":"https://api.github.com/users/USGS-R/received_events","type":"Organization","site_admin":false},"repo":{"id":33744797,"name":"soilmoisturetools","full_name":"USGS-R/soilmoisturetools","owner":{"login":"USGS-R","id":3188813,"avatar_url":"https://avatars0.githubusercontent.com/u/3188813?v=3","gravatar_id":"","url":"https://api.github.com/users/USGS-R","html_url":"https://github.com/USGS-R","followers_url":"https://api.github.com/users/USGS-R/followers","following_url":"https://api.github.com/users/USGS-R/following{/other_user}","gists_url":"https://api.github.com/users/USGS-R/gists{/gist_id}","starred_url":"https://api.github.com/users/USGS-R/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/USGS-R/subscriptions","organizations_url":"https://api.github.com/users/USGS-R/orgs","repos_url":"https://api.github.com/users/USGS-R/repos","events_url":"https://api.github.com/users/USGS-R/events{/privacy}","received_events_url":"https://api.github.com/users/USGS-R/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/USGS-R/soilmoisturetools","description":"Tools for soil moisture data retrieval and visualization","fork":false,"url":"https://api.github.com/repos/USGS-R/soilmoisturetools","forks_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/forks","keys_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/teams","hooks_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/hooks","issue_events_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/issues/events{/number}","events_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/events","assignees_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/assignees{/user}","branches_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/branches{/branch}","tags_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/tags","blobs_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/git/refs{/sha}","trees_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/statuses/{sha}","languages_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/languages","stargazers_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/stargazers","contributors_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/contributors","subscribers_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/subscribers","subscription_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/subscription","commits_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/commits{/sha}","git_commits_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/git/commits{/sha}","comments_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/comments{/number}","issue_comment_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/issues/comments{/number}","contents_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/contents/{+path}","compare_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/merges","archive_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/downloads","issues_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/issues{/number}","pulls_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls{/number}","milestones_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/milestones{/number}","notifications_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/labels{/name}","releases_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/releases{/id}","deployments_url":"https://api.github.com/repos/USGS-R/soilmoisturetools/deployments","created_at":"2015-04-10T18:43:37Z","updated_at":"2016-11-17T15:13:39Z","pushed_at":"2017-05-01T16:09:44Z","git_url":"git://github.com/USGS-R/soilmoisturetools.git","ssh_url":"git@github.com:USGS-R/soilmoisturetools.git","clone_url":"https://github.com/USGS-R/soilmoisturetools.git","svn_url":"https://github.com/USGS-R/soilmoisturetools","homepage":null,"size":2258,"stargazers_count":5,"watchers_count":5,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":5,"forks":10,"open_issues":5,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46"},"html":{"href":"https://github.com/USGS-R/soilmoisturetools/pull/46"},"issue":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/issues/46"},"comments":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/USGS-R/soilmoisturetools/statuses/800862b43f8c3a2520fd229959df0c85e457ad2a"}}}}
{"actor":{"display_login":"mhines-usgs"}}