shijithraghav / alexa_scrapping

0 stars 0 forks source link

[Question] Method to fetch old rank #2

Closed coderhs closed 7 years ago

coderhs commented 7 years ago

Curious on your choice of code to fetch the old rank. As going through all the ranks seems to be unnecessary and becomes slower with the number of ranks with respect to the a website increases.

@website.ranks.each do |rank|
        @old_rank = rank.rank
 end
shijithraghav commented 7 years ago

As you said, the process will be slower when it comes to large number of domains. so , I changed the code to

@old_rank = @website.ranks.first.rank