Module: GHTorrent::Commands::FullUserRetriever

Included in:
GHTRetrieveUser, GHTUserRetriever
Defined in:
lib/ghtorrent/commands/full_user_retriever.rb

Overview

Defines a process to download the full data available for a single user

Instance Method Summary collapse

Instance Method Details

#retrieve_user(login) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ghtorrent/commands/full_user_retriever.rb', line 6

def retrieve_user()
  #self.settings = override_config(settings, :mirror_history_pages_back, -1)

  user_entry = ght.transaction { ght.ensure_user(, false, false) }
  on_github = api_request(ghurl ("users/#{login}"))

  if on_github.empty?
    if user_entry.nil?
      warn "User #{login} does not exist on GitHub"
      exit
    else
      ght.transaction do
        ght.get_db.from(:users).where(:login => ).update(:users__deleted => true)
      end
      warn "User #{login} marked as deleted"
      return
    end
  else
    if user_entry.nil?
      warn "Error retrieving user #{login}"
      exit
    end
  end

  user = user_entry[:login]

  def send_message(function, user)
    begin
      ght.send(function, user)
    rescue StandardError => e
      puts STDERR, e.message
      puts STDERR, e.backtrace
    end
  end

  functions = %w(ensure_user_following ensure_user_followers ensure_orgs ensure_org)

  functions.each do |x|
    send_message(x, user)
  end

end

#send_message(function, user) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/ghtorrent/commands/full_user_retriever.rb', line 32

def send_message(function, user)
  begin
    ght.send(function, user)
  rescue StandardError => e
    puts STDERR, e.message
    puts STDERR, e.backtrace
  end
end