This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_at_connections() | |
values = [] | |
usernames = persons.collect{|p| p.username} | |
i = 0 | |
persons.each do |person| | |
t1 = Time.now | |
i += 1 | |
person.feed_entries.each do |tweet| | |
#puts "#Analyzing tweet #{tweet.id}" | |
usernames.each do |tmp_user| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A version that used delayed jobs to split the work among a lot of workers | |
# Deprecated because the bottleneck was querying the DB | |
# Same as find all valued connections only trying to make it faster | |
def find_delayed_at_connections(friend = true, follower = false, category = false) | |
usernames = persons.collect{|p| p.username} | |
persons.each do |person| | |
Delayed::Job.enqueue(AggregateAtConnectionsJob.new(person.id,self.id,usernames)) | |
end | |
wait_for_jobs("AggregateAtConnectionsJob") | |
self.return_delayed_at_connections |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper method that is used when creating delayed jobs. | |
def wait_for_jobs(jobname) | |
continue = true | |
while continue | |
found_pending_jobs = 0 | |
Delayed::Job.all.each do |job| | |
if job.handler.include? jobname | |
found_pending_jobs += 1 | |
end | |
if job.attempts >= 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Indexing the text field with solr | |
searchable do | |
text :text | |
integer :person_id | |
time :published_at | |
text :retweeters do | |
retweet_ids.collect{|retweet| retweet[:id]} | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_solr_at_connections | |
users = {} | |
persons.each do |person| | |
users[person.id] = person.username | |
end | |
values = [] | |
i = 0 | |
persons.each do |person| | |
i += 1 | |
t1 = Time.now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Person 1 archaeologymag. Time per person: 7.783559. | |
Person 2 ArchaeologyDN. Time per person: 1.097274. | |
Person 3 archaeologynews. Time per person: 0.085687. | |
Person 4 NEAarchaeology. Time per person: 0.184254. | |
Person 5 CurrentArchaeo. Time per person: 0.116461. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
puts Benchmark.measure{Project.find(1).find_at_connections} | |
31.660000 0.540000 32.200000 ( 35.293887) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require '../config/environment' | |
interests = {} | |
rows = FasterCSV.read("#{RAILS_ROOT}/analysis/data/partitions/final_partitions_p100_200_0.2.csv") | |
rows.each do |row| | |
interests[row[0]] = {:category => row[1], :count => row[2]} | |
end | |
project = Project.last | |
ids = project.persons.collect{|p| p.twitter_id} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- - tech | |
- :count: 13 | |
:names: | |
- - BillGates | |
- "7" | |
- - biz | |
- "23" | |
- - ev | |
- "17" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
07/08/2014 | |
5:28 pm | |
The battle is on! Im heutigen #HomeRunjoiz-Fight stehen sich Rap und Rock gegenüber: DritteStock vs. Dirty Sound Magnet! Jetzt auf www.joiz.ch/LIVE mitchatten und mit deiner Stimme im Voting über Sieg oder Niederlage entscheiden! | |
Photo | |
Public | |
0 | |
Organic | |
0 | |
Paid | |
0 |