Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crawler may missing activities #37

Merged
merged 1 commit into from Sep 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions crawler/crawler.rb
Expand Up @@ -23,6 +23,7 @@
}))

@latest = []
@latest_key = lambda { |e| "#{e['type']}:#{e['actor']}:#{e['url']}:#{e['created_at']}" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the cases where URL is not unique by itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
created_at: "2013-09-22T09:05:14-07:00",
payload: {
action: "started"
},
public: true,
type: "WatchEvent",
url: "https://github.com/lzyy/thing",
actor: "haolloyin",
...
}


##
## Crawler
Expand Down Expand Up @@ -66,8 +67,8 @@
req.callback do
begin
latest = Yajl::Parser.parse(req.response)
urls = latest.collect {|e| e['url']}
new_events = latest.reject {|e| @latest.include? e['url']}
urls = latest.collect(&@latest_key)
new_events = latest.reject {|e| @latest.include? @latest_key.call(e)}

@latest = urls
new_events.each do |event|
Expand Down