{"action":"created","comment":{"url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments/91022518","pull_request_review_id":11532906,"id":91022518,"diff_hunk":"@@ -0,0 +1,275 @@\n+require 'active_support/logger'\n+\n+\n+namespace :shf do\n+\n+  desc 'recreate db (current env): drop, setup, migrate, seed the db.'\n+  task :db_recreate => [:environment] do\n+    tasks = ['db:drop', 'db:setup', 'db:migrate', 'db:seed']\n+    tasks.each { |t| Rake::Task[\"#{t}\"].invoke }\n+  end\n+\n+\n+  desc \"get valid company numbers from a text file. Expects to find them as Org no556357-3046 (no space after 'Org no'\"\n+  task :get_valid_companyNums, [:text_file] => [:environment] do |t, args|\n+    # ex: text copied from https://foretagsfakta.bolagsverket.se/fpl-dft-ext-web/home.seam?actionMethod=home.xhtml%3Asearch.sokning.prevPage&cid=234026\n+\n+    usage = 'rake shf:get_valid_companyNums[\"./spec/fixtures/test-import-files/company-numbers-source.txt\"]'\n+    match_pattern = /Org no(\\d\\d\\d\\d\\d\\d-\\d\\d\\d\\d)/\n+\n+    start_time = Time.now\n+    log = start_logging(start_time)\n+\n+    if args.has_key? :text_file\n+\n+      if File.exist? args[:text_file]\n+        contents = File.open(args[:text_file], 'r') { |f| f.read }\n+\n+        company_numbers = contents.scan match_pattern\n+        log_and_show log, Logger::INFO, \"#{company_numbers.flatten}\"\n+\n+      else\n+        log_file_doesnt_exist_and_close(log, args[:text_file], start_time)\n+        raise LoadError\n+      end\n+    else\n+      log_must_provide_filename_and_close(log, usage, start_time)\n+      raise \"ERROR: You must specify a .csv filename to import. Ex: #{usage}\"\n+    end\n+\n+    finish_and_close_log(log, start_time, Time.now)\n+  end\n+\n+\n+  desc \"import membership apps from csv file. Provide the full filename (with path)\"\n+  task :import_membership_apps, [:csv_filename] => [:environment] do |t, args|","path":"lib/tasks/shf.rake","position":45,"original_position":45,"commit_id":"5c06a550d939cd3c43d864c78ba18d6e36785397","original_commit_id":"5c06a550d939cd3c43d864c78ba18d6e36785397","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Unused block argument - t. If it's necessary, use _ or _t as an argument name to indicate that it won't be used.","created_at":"2016-12-06T07:13:42Z","updated_at":"2016-12-06T07:13:42Z","html_url":"https://github.com/AgileVentures/shf-project/pull/56#discussion_r91022518","pull_request_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments/91022518"},"html":{"href":"https://github.com/AgileVentures/shf-project/pull/56#discussion_r91022518"},"pull_request":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56","id":96433526,"html_url":"https://github.com/AgileVentures/shf-project/pull/56","diff_url":"https://github.com/AgileVentures/shf-project/pull/56.diff","patch_url":"https://github.com/AgileVentures/shf-project/pull/56.patch","issue_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/56","number":56,"state":"open","locked":false,"title":"Import Membership Info from Existing System","user":{"login":"thesuss","id":7266909,"avatar_url":"https://avatars.githubusercontent.com/u/7266909?v=3","gravatar_id":"","url":"https://api.github.com/users/thesuss","html_url":"https://github.com/thesuss","followers_url":"https://api.github.com/users/thesuss/followers","following_url":"https://api.github.com/users/thesuss/following{/other_user}","gists_url":"https://api.github.com/users/thesuss/gists{/gist_id}","starred_url":"https://api.github.com/users/thesuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thesuss/subscriptions","organizations_url":"https://api.github.com/users/thesuss/orgs","repos_url":"https://api.github.com/users/thesuss/repos","events_url":"https://api.github.com/users/thesuss/events{/privacy}","received_events_url":"https://api.github.com/users/thesuss/received_events","type":"User","site_admin":false},"body":"Replaces #51 because I messed that up somehow\r\n\r\nPT Story:  **Import Membership Info from Existing System**\r\nhttps://www.pivotaltracker.com/epic/show/3132625\r\n\r\nRun `bundle exec rake --tasks`  see the rake tasks added by this PR.\r\nAll tasks start with `shf:`\r\n\r\nThe rake task `import_membership_apps` that reads a CSV file with membership-application data, then creates users, membership applications, and companies as necessary.\r\n\r\nThis is still a work in progress.  Still need to:\r\n- write tests (it's possible now that I have good working output)\r\n- handle utf-8 characters\r\n\r\nBut it **_will_** read in a file and create the objects needed in the db, and write to a log file.\r\n\r\n\r\n---\r\nChanges proposed in this pull request:\r\n1. rake task named `shf:db_recreate`  that drops the db, sets it up, and seeds.  (Handy when you need to load and reload data.  Also handy when you're merging a branch (like pulling develop) and want to be sure your db is recreated.\r\n\r\n2.  created a sanitized csv files for importing:\r\n   - users-sanitized.csv -- replaced the organization numbers with valid numbers from the internet\r\n   - member-companies-sanitized-small.csv -- 15 rows taken from the member-companies.csv file, then replaced the organization numbers with valid numbers from the internet\r\n      - note that this file purposefully has some errors in it.\r\n\r\n3. rake task `get_valid_companyNums` helped me get some valid company numbers from the web.  It just looks in a text file and does pattern matching to find *Org no`dddddd-dddd`* (where `d` is a digit).  It writes them to the log file and also outputs to the screen via puts.\r\n\r\n4. rake task `import_membership_apps` reads a csv file, then creates the objects needed and populates the database.  Writes messages to the screen and to a log file.\r\n","created_at":"2016-12-04T14:07:20Z","updated_at":"2016-12-06T07:13:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddd4265db5a063baa1bf95dedcbfa00c84b7b3b6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56/commits","review_comments_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56/comments","review_comment_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/56/comments","statuses_url":"https://api.github.com/repos/AgileVentures/shf-project/statuses/5c06a550d939cd3c43d864c78ba18d6e36785397","head":{"label":"thesuss:fix-51","ref":"fix-51","sha":"5c06a550d939cd3c43d864c78ba18d6e36785397","user":{"login":"thesuss","id":7266909,"avatar_url":"https://avatars.githubusercontent.com/u/7266909?v=3","gravatar_id":"","url":"https://api.github.com/users/thesuss","html_url":"https://github.com/thesuss","followers_url":"https://api.github.com/users/thesuss/followers","following_url":"https://api.github.com/users/thesuss/following{/other_user}","gists_url":"https://api.github.com/users/thesuss/gists{/gist_id}","starred_url":"https://api.github.com/users/thesuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thesuss/subscriptions","organizations_url":"https://api.github.com/users/thesuss/orgs","repos_url":"https://api.github.com/users/thesuss/repos","events_url":"https://api.github.com/users/thesuss/events{/privacy}","received_events_url":"https://api.github.com/users/thesuss/received_events","type":"User","site_admin":false},"repo":{"id":65629235,"name":"shf-project","full_name":"thesuss/shf-project","owner":{"login":"thesuss","id":7266909,"avatar_url":"https://avatars.githubusercontent.com/u/7266909?v=3","gravatar_id":"","url":"https://api.github.com/users/thesuss","html_url":"https://github.com/thesuss","followers_url":"https://api.github.com/users/thesuss/followers","following_url":"https://api.github.com/users/thesuss/following{/other_user}","gists_url":"https://api.github.com/users/thesuss/gists{/gist_id}","starred_url":"https://api.github.com/users/thesuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thesuss/subscriptions","organizations_url":"https://api.github.com/users/thesuss/orgs","repos_url":"https://api.github.com/users/thesuss/repos","events_url":"https://api.github.com/users/thesuss/events{/privacy}","received_events_url":"https://api.github.com/users/thesuss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thesuss/shf-project","description":"This is the repo for what will be membership handling of Sveriges Hundföretagare","fork":false,"url":"https://api.github.com/repos/thesuss/shf-project","forks_url":"https://api.github.com/repos/thesuss/shf-project/forks","keys_url":"https://api.github.com/repos/thesuss/shf-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thesuss/shf-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thesuss/shf-project/teams","hooks_url":"https://api.github.com/repos/thesuss/shf-project/hooks","issue_events_url":"https://api.github.com/repos/thesuss/shf-project/issues/events{/number}","events_url":"https://api.github.com/repos/thesuss/shf-project/events","assignees_url":"https://api.github.com/repos/thesuss/shf-project/assignees{/user}","branches_url":"https://api.github.com/repos/thesuss/shf-project/branches{/branch}","tags_url":"https://api.github.com/repos/thesuss/shf-project/tags","blobs_url":"https://api.github.com/repos/thesuss/shf-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thesuss/shf-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thesuss/shf-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/thesuss/shf-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thesuss/shf-project/statuses/{sha}","languages_url":"https://api.github.com/repos/thesuss/shf-project/languages","stargazers_url":"https://api.github.com/repos/thesuss/shf-project/stargazers","contributors_url":"https://api.github.com/repos/thesuss/shf-project/contributors","subscribers_url":"https://api.github.com/repos/thesuss/shf-project/subscribers","subscription_url":"https://api.github.com/repos/thesuss/shf-project/subscription","commits_url":"https://api.github.com/repos/thesuss/shf-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/thesuss/shf-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/thesuss/shf-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/thesuss/shf-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/thesuss/shf-project/contents/{+path}","compare_url":"https://api.github.com/repos/thesuss/shf-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thesuss/shf-project/merges","archive_url":"https://api.github.com/repos/thesuss/shf-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thesuss/shf-project/downloads","issues_url":"https://api.github.com/repos/thesuss/shf-project/issues{/number}","pulls_url":"https://api.github.com/repos/thesuss/shf-project/pulls{/number}","milestones_url":"https://api.github.com/repos/thesuss/shf-project/milestones{/number}","notifications_url":"https://api.github.com/repos/thesuss/shf-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thesuss/shf-project/labels{/name}","releases_url":"https://api.github.com/repos/thesuss/shf-project/releases{/id}","deployments_url":"https://api.github.com/repos/thesuss/shf-project/deployments","created_at":"2016-08-13T17:38:08Z","updated_at":"2016-10-22T10:45:07Z","pushed_at":"2016-12-06T07:13:33Z","git_url":"git://github.com/thesuss/shf-project.git","ssh_url":"git@github.com:thesuss/shf-project.git","clone_url":"https://github.com/thesuss/shf-project.git","svn_url":"https://github.com/thesuss/shf-project","homepage":"http://www.sverigeshundforetagare.se","size":1492,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":1,"forks":10,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"AgileVentures:develop","ref":"develop","sha":"9ee9bf93102f586e4d5413cfcc3f04f0234d8eea","user":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars.githubusercontent.com/u/5116968?v=3","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"repo":{"id":71157737,"name":"shf-project","full_name":"AgileVentures/shf-project","owner":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars.githubusercontent.com/u/5116968?v=3","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AgileVentures/shf-project","description":null,"fork":true,"url":"https://api.github.com/repos/AgileVentures/shf-project","forks_url":"https://api.github.com/repos/AgileVentures/shf-project/forks","keys_url":"https://api.github.com/repos/AgileVentures/shf-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AgileVentures/shf-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AgileVentures/shf-project/teams","hooks_url":"https://api.github.com/repos/AgileVentures/shf-project/hooks","issue_events_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/events{/number}","events_url":"https://api.github.com/repos/AgileVentures/shf-project/events","assignees_url":"https://api.github.com/repos/AgileVentures/shf-project/assignees{/user}","branches_url":"https://api.github.com/repos/AgileVentures/shf-project/branches{/branch}","tags_url":"https://api.github.com/repos/AgileVentures/shf-project/tags","blobs_url":"https://api.github.com/repos/AgileVentures/shf-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AgileVentures/shf-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AgileVentures/shf-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/AgileVentures/shf-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AgileVentures/shf-project/statuses/{sha}","languages_url":"https://api.github.com/repos/AgileVentures/shf-project/languages","stargazers_url":"https://api.github.com/repos/AgileVentures/shf-project/stargazers","contributors_url":"https://api.github.com/repos/AgileVentures/shf-project/contributors","subscribers_url":"https://api.github.com/repos/AgileVentures/shf-project/subscribers","subscription_url":"https://api.github.com/repos/AgileVentures/shf-project/subscription","commits_url":"https://api.github.com/repos/AgileVentures/shf-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/AgileVentures/shf-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/AgileVentures/shf-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/AgileVentures/shf-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/AgileVentures/shf-project/contents/{+path}","compare_url":"https://api.github.com/repos/AgileVentures/shf-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AgileVentures/shf-project/merges","archive_url":"https://api.github.com/repos/AgileVentures/shf-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AgileVentures/shf-project/downloads","issues_url":"https://api.github.com/repos/AgileVentures/shf-project/issues{/number}","pulls_url":"https://api.github.com/repos/AgileVentures/shf-project/pulls{/number}","milestones_url":"https://api.github.com/repos/AgileVentures/shf-project/milestones{/number}","notifications_url":"https://api.github.com/repos/AgileVentures/shf-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AgileVentures/shf-project/labels{/name}","releases_url":"https://api.github.com/repos/AgileVentures/shf-project/releases{/id}","deployments_url":"https://api.github.com/repos/AgileVentures/shf-project/deployments","created_at":"2016-10-17T16:18:10Z","updated_at":"2016-12-02T13:34:05Z","pushed_at":"2016-12-06T07:13:33Z","git_url":"git://github.com/AgileVentures/shf-project.git","ssh_url":"git@github.com:AgileVentures/shf-project.git","clone_url":"https://github.com/AgileVentures/shf-project.git","svn_url":"https://github.com/AgileVentures/shf-project","homepage":null,"size":1646,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":3,"forks":9,"open_issues":3,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56"},"html":{"href":"https://github.com/AgileVentures/shf-project/pull/56"},"issue":{"href":"https://api.github.com/repos/AgileVentures/shf-project/issues/56"},"comments":{"href":"https://api.github.com/repos/AgileVentures/shf-project/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AgileVentures/shf-project/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/AgileVentures/shf-project/statuses/5c06a550d939cd3c43d864c78ba18d6e36785397"}}}}
{"actor":{"display_login":"houndci-bot"}}