Skip to content

Instantly share code, notes, and snippets.

@phensalves
Last active May 28, 2017 07:56
Show Gist options
  • Save phensalves/12aec6cd6b643eb595826715bb063ebe to your computer and use it in GitHub Desktop.
Save phensalves/12aec6cd6b643eb595826715bb063ebe to your computer and use it in GitHub Desktop.
controller
class TweetsController < ApplicationController
def most_relevants
process_most_relevants
end
def most_mentions
process_most_mentions
end
private
def process_most_relevants
prepare_hash
sort_most_relevants(@elegible_tweets)
@elegible_tweets = @tweets_sorted
@elegible_tweets = beautify_json_response(@elegible_tweets)
end
def process_most_mentions
prepare_hash
sort_most_relevants(@elegible_tweets)
@elegible_tweets = @tweets_sorted
group_tweets_by_user(@elegible_tweets)
@elegible_tweets = @tweets_grouped_by_user
@elegible_tweets = beautify_json_response(@elegible_tweets)
end
def prepare_hash
connect_to_api
build_tweets_hash(@elegible_tweets)
@elegible_tweets = @tweets_array
end
def connect_to_api
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment