GitHub PullRequestReviewCommentEvent at 2014-09-19 07:44:56
Repository: data
Actor: stonew
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/fangdiantong/data/pulls/comments/17772494","id":17772494,"diff_hunk":"@@ -0,0 +1,160 @@\n+package fangdd.pipeline.ads.api;\n+\n+import java.util.Date;\n+import java.util.Map;\n+import java.util.Set;\n+\n+import org.apache.commons.lang.time.DateFormatUtils;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import com.external.common.flags.Flag;\n+import com.external.common.flags.FlagInfo;\n+import com.external.common.flags.Flags;\n+import com.google.common.base.Strings;\n+import com.mongodb.BasicDBObject;\n+import com.mongodb.DB;\n+import com.mongodb.DBCollection;\n+\n+import fangdd.pipeline.ads.account.AdsAccountManager;\n+import fangdd.pipeline.ads.account.AdsAccountManager.AdsAccount;\n+import fangdd.pipeline.ads.account.AdsAccountManager.ChannelType;\n+import fangdd.pipeline.ads.email.Email;\n+import fangdd.pipeline.ads.importer.AdsReportImporter;\n+import fangdd.pipeline.ads.importer.DianjingFileImporter;\n+import fangdd.pipeline.ads.importer.SougouFileImporter;\n+import fangdd.pipeline.ads.util.DateTimeUtil;\n+import fangdd.pipeline.ads.util.MongoLayer;\n+\n+public class AdsReportUtils {\n+\n+\tprivate static Logger logger = LoggerFactory.getLogger(AdsReportUtils.class\n+\t\t\t.getCanonicalName());\n+\t@FlagInfo(help = \"emailhost\", altName = \"host\")\n+\tprivate static Flag<String> emailhost = Flags.valueOf(\"smtp.126.com\");\n+\t@FlagInfo(help = \"addressfrom\", altName = \"from\")\n+\tprivate static Flag<String> addressfrom = Flags\n+\t\t\t.valueOf(\"stone_test@126.com\");\n+\t@FlagInfo(help = \"addressto\", altName = \"to\")\n+\tprivate static Flag<String> addressto = Flags.valueOf(\"709251510@qq.com\");\n+\n+\tpublic static final String ADSTYPE        = \"SEM\";\n+\t\n+\t\n+\tpublic static AdsReportApi getAdsReportApiImpl(ChannelType channel,\n+\t\t\tAdsAccount account, DB db, Email adsApiEmail) {\n+\n+\t\tswitch (channel) {\n+\t\t\tcase DIAN_JING:\n+\t\t\t\treturn new DianjingAPI(account, db, adsApiEmail);\n+\t\t\tcase SOGOU:\n+\t\t\t\treturn new SougouAPI(account, db, adsApiEmail);\n+\t\t\tdefault:\n+\t\t\t\tlogger.error(\"not supported this enum, May not have developed \");\n+\t\t\t\tbreak;\n+\t\t}\n+\t\treturn null;\n+\t}\n+\n+\tprivate static AdsReportImporter getAdsReportImporterImpl(\n+\t\t\tChannelType channel, AdsAccount account, DB db, Email adsApiEmail) {\n+\n+\t\tswitch (channel) {\n+\t\t\tcase DIAN_JING:\n+\t\t\t\treturn new DianjingFileImporter(account, db, adsApiEmail);\n+\t\t\tcase SOGOU:\n+\t\t\t\treturn new SougouFileImporter(account, db, adsApiEmail);\n+\t\t\tdefault:\n+\t\t\t\tlogger.error(\"not supported this enum, May not have developed \");\n+\t\t\t\tbreak;\n+\t\t}\n+\t\treturn null;\n+\t}\n+\n+\tpublic static void fetchAndSaveOneDayReport(String strDate,\n+\t\t\tString dataType, String path, String adChannel) {\n+\n+\t\ttry {\n+\t\t\tEmail email = Email.getMail(emailhost.get(), addressfrom.get(),\n+\t\t\t\t\taddressto.get());\n+\t\t\tAdsReportApi adsReportApi = null;\n+\t\t\tDB db = MongoLayer.loadMongoDb(MongoLayer.fdd_ads_mongodb.get());\n+\t\t\tfor (ChannelType channel : ChannelType.values()) {\n+\t\t\t\tif (!Strings.isNullOrEmpty(adChannel)\n+\t\t\t\t\t\t&& !adChannel.equals(channel.name())) {\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n+\n+\t\t\t\tAdsAccountManager adsAccountManager = new AdsAccountManager();\t\t\t\t\n+\t\t\t\tfor (AdsAccount adsAccount : adsAccountManager.getAccounts(channel)) {\n+\t\t\t\t\t\n+\t\t\t\t\tadsReportApi = getAdsReportApiImpl(\n+\t\t\t\t\t\t\tchannel,\n+\t\t\t\t\t\t\tadsAccount,\n+\t\t\t\t\t\t\tdb,\n+\t\t\t\t\t\t\temail);\n+\t\t\t\t\tadsReportApi.fetchAndSaveOneDayReport(\n+\t\t\t\t\t\t\tstrDate,\n+\t\t\t\t\t\t\tdataType,\n+\t\t\t\t\t\t\tpath);\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t} catch (Exception e) {\t\t\t\n+\t\t\tlogger.error(\"AdsReportUtils-fetchAndSaveOneDayReport error\\n\" +\n+\t\t                  e.getStackTrace().toString());\n+\t\t}\n+\t}\n+\n+\tpublic static void importOneDayReport(String strDate, String dataType,\n+\t\t\tString path, String adChannel) {\n+\t\t\n+\t\ttry {\n+\t\t\tEmail email = Email.getMail(\n+\t\t\t\t\temailhost.get(),\n+\t\t\t\t\taddressfrom.get(),\n+\t\t\t\t\taddressto.get());\n+\t\t\tAdsReportImporter adsReportImporter = null;\n+\t\t\tDB db = MongoLayer.loadMongoDb(MongoLayer.fdd_ads_mongodb.get());\n+\t\t\tfor (ChannelType channel : ChannelType.values()) {\n+\t\t\t\t\n+\t\t\t\tif (!Strings.isNullOrEmpty(adChannel)\n+\t\t\t\t\t\t&& !adChannel.equals(channel.name())) {\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n+\t\t\t\tAdsAccountManager adsAccountManager = new AdsAccountManager();\t\t\t\t\n+\t\t\t\tfor (AdsAccount adsAccount : adsAccountManager.getAccounts(channel)) {\n+\t\t\t\t\tadsReportImporter = getAdsReportImporterImpl(\n+\t\t\t\t\t\t\tchannel,","path":"fdd_ads_pipeline/src/main/java/fangdd/pipeline/ads/api/AdsReportUtils.java","position":128,"original_position":128,"commit_id":"b04c4733aa793a26177356906c8709d88eecd6ce","original_commit_id":"b04c4733aa793a26177356906c8709d88eecd6ce","user":{"login":"stonew","id":8415449,"avatar_url":"https://avatars.githubusercontent.com/u/8415449?v=2","gravatar_id":"8c25a321abc23b63b72deb0b09b27d51","url":"https://api.github.com/users/stonew","html_url":"https://github.com/stonew","followers_url":"https://api.github.com/users/stonew/followers","following_url":"https://api.github.com/users/stonew/following{/other_user}","gists_url":"https://api.github.com/users/stonew/gists{/gist_id}","starred_url":"https://api.github.com/users/stonew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonew/subscriptions","organizations_url":"https://api.github.com/users/stonew/orgs","repos_url":"https://api.github.com/users/stonew/repos","events_url":"https://api.github.com/users/stonew/events{/privacy}","received_events_url":"https://api.github.com/users/stonew/received_events","type":"User","site_admin":false},"body":"ok","created_at":"2014-09-19T07:44:56Z","updated_at":"2014-09-19T07:44:56Z","html_url":"https://github.com/fangdiantong/data/pull/63#discussion_r17772494","pull_request_url":"https://api.github.com/repos/fangdiantong/data/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/fangdiantong/data/pulls/comments/17772494"},"html":{"href":"https://github.com/fangdiantong/data/pull/63#discussion_r17772494"},"pull_request":{"href":"https://api.github.com/repos/fangdiantong/data/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/fangdiantong/data/pulls/63","id":21221559,"html_url":"https://github.com/fangdiantong/data/pull/63","diff_url":"https://github.com/fangdiantong/data/pull/63.diff","patch_url":"https://github.com/fangdiantong/data/pull/63.patch","issue_url":"https://api.github.com/repos/fangdiantong/data/issues/63","number":63,"state":"open","locked":false,"title":"搜狗 360 api 更改","user":{"login":"stonew","id":8415449,"avatar_url":"https://avatars.githubusercontent.com/u/8415449?v=2","gravatar_id":"8c25a321abc23b63b72deb0b09b27d51","url":"https://api.github.com/users/stonew","html_url":"https://github.com/stonew","followers_url":"https://api.github.com/users/stonew/followers","following_url":"https://api.github.com/users/stonew/following{/other_user}","gists_url":"https://api.github.com/users/stonew/gists{/gist_id}","starred_url":"https://api.github.com/users/stonew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonew/subscriptions","organizations_url":"https://api.github.com/users/stonew/orgs","repos_url":"https://api.github.com/users/stonew/repos","events_url":"https://api.github.com/users/stonew/events{/privacy}","received_events_url":"https://api.github.com/users/stonew/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-09-15T09:41:05Z","updated_at":"2014-09-19T07:44:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e28e7ab03b127be4817d24a46a36a110ef6ed811","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fangdiantong/data/pulls/63/commits","review_comments_url":"https://api.github.com/repos/fangdiantong/data/pulls/63/comments","review_comment_url":"https://api.github.com/repos/fangdiantong/data/pulls/comments/{number}","comments_url":"https://api.github.com/repos/fangdiantong/data/issues/63/comments","statuses_url":"https://api.github.com/repos/fangdiantong/data/statuses/b04c4733aa793a26177356906c8709d88eecd6ce","head":{"label":"fangdiantong:stonew1","ref":"stonew1","sha":"b04c4733aa793a26177356906c8709d88eecd6ce","user":{"login":"fangdiantong","id":8415207,"avatar_url":"https://avatars.githubusercontent.com/u/8415207?v=2","gravatar_id":null,"url":"https://api.github.com/users/fangdiantong","html_url":"https://github.com/fangdiantong","followers_url":"https://api.github.com/users/fangdiantong/followers","following_url":"https://api.github.com/users/fangdiantong/following{/other_user}","gists_url":"https://api.github.com/users/fangdiantong/gists{/gist_id}","starred_url":"https://api.github.com/users/fangdiantong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fangdiantong/subscriptions","organizations_url":"https://api.github.com/users/fangdiantong/orgs","repos_url":"https://api.github.com/users/fangdiantong/repos","events_url":"https://api.github.com/users/fangdiantong/events{/privacy}","received_events_url":"https://api.github.com/users/fangdiantong/received_events","type":"Organization","site_admin":false},"repo":{"id":22837137,"name":"data","full_name":"fangdiantong/data","owner":{"login":"fangdiantong","id":8415207,"avatar_url":"https://avatars.githubusercontent.com/u/8415207?v=2","gravatar_id":null,"url":"https://api.github.com/users/fangdiantong","html_url":"https://github.com/fangdiantong","followers_url":"https://api.github.com/users/fangdiantong/followers","following_url":"https://api.github.com/users/fangdiantong/following{/other_user}","gists_url":"https://api.github.com/users/fangdiantong/gists{/gist_id}","starred_url":"https://api.github.com/users/fangdiantong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fangdiantong/subscriptions","organizations_url":"https://api.github.com/users/fangdiantong/orgs","repos_url":"https://api.github.com/users/fangdiantong/repos","events_url":"https://api.github.com/users/fangdiantong/events{/privacy}","received_events_url":"https://api.github.com/users/fangdiantong/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fangdiantong/data","description":"","fork":true,"url":"https://api.github.com/repos/fangdiantong/data","forks_url":"https://api.github.com/repos/fangdiantong/data/forks","keys_url":"https://api.github.com/repos/fangdiantong/data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fangdiantong/data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fangdiantong/data/teams","hooks_url":"https://api.github.com/repos/fangdiantong/data/hooks","issue_events_url":"https://api.github.com/repos/fangdiantong/data/issues/events{/number}","events_url":"https://api.github.com/repos/fangdiantong/data/events","assignees_url":"https://api.github.com/repos/fangdiantong/data/assignees{/user}","branches_url":"https://api.github.com/repos/fangdiantong/data/branches{/branch}","tags_url":"https://api.github.com/repos/fangdiantong/data/tags","blobs_url":"https://api.github.com/repos/fangdiantong/data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fangdiantong/data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fangdiantong/data/git/refs{/sha}","trees_url":"https://api.github.com/repos/fangdiantong/data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fangdiantong/data/statuses/{sha}","languages_url":"https://api.github.com/repos/fangdiantong/data/languages","stargazers_url":"https://api.github.com/repos/fangdiantong/data/stargazers","contributors_url":"https://api.github.com/repos/fangdiantong/data/contributors","subscribers_url":"https://api.github.com/repos/fangdiantong/data/subscribers","subscription_url":"https://api.github.com/repos/fangdiantong/data/subscription","commits_url":"https://api.github.com/repos/fangdiantong/data/commits{/sha}","git_commits_url":"https://api.github.com/repos/fangdiantong/data/git/commits{/sha}","comments_url":"https://api.github.com/repos/fangdiantong/data/comments{/number}","issue_comment_url":"https://api.github.com/repos/fangdiantong/data/issues/comments/{number}","contents_url":"https://api.github.com/repos/fangdiantong/data/contents/{+path}","compare_url":"https://api.github.com/repos/fangdiantong/data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fangdiantong/data/merges","archive_url":"https://api.github.com/repos/fangdiantong/data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fangdiantong/data/downloads","issues_url":"https://api.github.com/repos/fangdiantong/data/issues{/number}","pulls_url":"https://api.github.com/repos/fangdiantong/data/pulls{/number}","milestones_url":"https://api.github.com/repos/fangdiantong/data/milestones{/number}","notifications_url":"https://api.github.com/repos/fangdiantong/data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fangdiantong/data/labels{/name}","releases_url":"https://api.github.com/repos/fangdiantong/data/releases{/id}","created_at":"2014-08-11T11:44:47Z","updated_at":"2014-08-12T09:55:26Z","pushed_at":"2014-09-19T03:56:04Z","git_url":"git://github.com/fangdiantong/data.git","ssh_url":"git@github.com:fangdiantong/data.git","clone_url":"https://github.com/fangdiantong/data.git","svn_url":"https://github.com/fangdiantong/data","homepage":null,"size":20431,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"fangdiantong:master","ref":"master","sha":"1990acff53a180d6c833f6c0fd7845b2bb2d043f","user":{"login":"fangdiantong","id":8415207,"avatar_url":"https://avatars.githubusercontent.com/u/8415207?v=2","gravatar_id":null,"url":"https://api.github.com/users/fangdiantong","html_url":"https://github.com/fangdiantong","followers_url":"https://api.github.com/users/fangdiantong/followers","following_url":"https://api.github.com/users/fangdiantong/following{/other_user}","gists_url":"https://api.github.com/users/fangdiantong/gists{/gist_id}","starred_url":"https://api.github.com/users/fangdiantong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fangdiantong/subscriptions","organizations_url":"https://api.github.com/users/fangdiantong/orgs","repos_url":"https://api.github.com/users/fangdiantong/repos","events_url":"https://api.github.com/users/fangdiantong/events{/privacy}","received_events_url":"https://api.github.com/users/fangdiantong/received_events","type":"Organization","site_admin":false},"repo":{"id":22837137,"name":"data","full_name":"fangdiantong/data","owner":{"login":"fangdiantong","id":8415207,"avatar_url":"https://avatars.githubusercontent.com/u/8415207?v=2","gravatar_id":null,"url":"https://api.github.com/users/fangdiantong","html_url":"https://github.com/fangdiantong","followers_url":"https://api.github.com/users/fangdiantong/followers","following_url":"https://api.github.com/users/fangdiantong/following{/other_user}","gists_url":"https://api.github.com/users/fangdiantong/gists{/gist_id}","starred_url":"https://api.github.com/users/fangdiantong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fangdiantong/subscriptions","organizations_url":"https://api.github.com/users/fangdiantong/orgs","repos_url":"https://api.github.com/users/fangdiantong/repos","events_url":"https://api.github.com/users/fangdiantong/events{/privacy}","received_events_url":"https://api.github.com/users/fangdiantong/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fangdiantong/data","description":"","fork":true,"url":"https://api.github.com/repos/fangdiantong/data","forks_url":"https://api.github.com/repos/fangdiantong/data/forks","keys_url":"https://api.github.com/repos/fangdiantong/data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fangdiantong/data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fangdiantong/data/teams","hooks_url":"https://api.github.com/repos/fangdiantong/data/hooks","issue_events_url":"https://api.github.com/repos/fangdiantong/data/issues/events{/number}","events_url":"https://api.github.com/repos/fangdiantong/data/events","assignees_url":"https://api.github.com/repos/fangdiantong/data/assignees{/user}","branches_url":"https://api.github.com/repos/fangdiantong/data/branches{/branch}","tags_url":"https://api.github.com/repos/fangdiantong/data/tags","blobs_url":"https://api.github.com/repos/fangdiantong/data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fangdiantong/data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fangdiantong/data/git/refs{/sha}","trees_url":"https://api.github.com/repos/fangdiantong/data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fangdiantong/data/statuses/{sha}","languages_url":"https://api.github.com/repos/fangdiantong/data/languages","stargazers_url":"https://api.github.com/repos/fangdiantong/data/stargazers","contributors_url":"https://api.github.com/repos/fangdiantong/data/contributors","subscribers_url":"https://api.github.com/repos/fangdiantong/data/subscribers","subscription_url":"https://api.github.com/repos/fangdiantong/data/subscription","commits_url":"https://api.github.com/repos/fangdiantong/data/commits{/sha}","git_commits_url":"https://api.github.com/repos/fangdiantong/data/git/commits{/sha}","comments_url":"https://api.github.com/repos/fangdiantong/data/comments{/number}","issue_comment_url":"https://api.github.com/repos/fangdiantong/data/issues/comments/{number}","contents_url":"https://api.github.com/repos/fangdiantong/data/contents/{+path}","compare_url":"https://api.github.com/repos/fangdiantong/data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fangdiantong/data/merges","archive_url":"https://api.github.com/repos/fangdiantong/data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fangdiantong/data/downloads","issues_url":"https://api.github.com/repos/fangdiantong/data/issues{/number}","pulls_url":"https://api.github.com/repos/fangdiantong/data/pulls{/number}","milestones_url":"https://api.github.com/repos/fangdiantong/data/milestones{/number}","notifications_url":"https://api.github.com/repos/fangdiantong/data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fangdiantong/data/labels{/name}","releases_url":"https://api.github.com/repos/fangdiantong/data/releases{/id}","created_at":"2014-08-11T11:44:47Z","updated_at":"2014-08-12T09:55:26Z","pushed_at":"2014-09-19T03:56:04Z","git_url":"git://github.com/fangdiantong/data.git","ssh_url":"git@github.com:fangdiantong/data.git","clone_url":"https://github.com/fangdiantong/data.git","svn_url":"https://github.com/fangdiantong/data","homepage":null,"size":20431,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fangdiantong/data/pulls/63"},"html":{"href":"https://github.com/fangdiantong/data/pull/63"},"issue":{"href":"https://api.github.com/repos/fangdiantong/data/issues/63"},"comments":{"href":"https://api.github.com/repos/fangdiantong/data/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/fangdiantong/data/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/fangdiantong/data/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/fangdiantong/data/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/fangdiantong/data/statuses/b04c4733aa793a26177356906c8709d88eecd6ce"}}}}