Skip to content

Instantly share code, notes, and snippets.

@yannvery
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save yannvery/9113477 to your computer and use it in GitHub Desktop.

Select an option

Save yannvery/9113477 to your computer and use it in GitHub Desktop.
Update Global News Rating with an Admin user
action_item :only => :show do
link_to 'Update Global Rating News', admin_update_global_rating_news_path(:id => celebrity.id), :confirm => "Etes vous sur ?"
end
def update_global_rating_news
@celebrity = Celebrity.find(params[:id]) if current_user.role? :admin
if [email protected]?
g_count = @celebrity.get_google_count("news")
if g_count != -1
@celebrity.update_column('google_news_count', g_count)
@celebrity.update_column('google_news_updated_at', Time.now)
@celebrity.update_column('google_news_rating', @celebrity.calc_google_rating("news"))
end
y_count = @celebrity.get_yahoo_count("news")
if y_count != -1
@celebrity.update_column('yahoo_news_count', y_count)
@celebrity.update_column('yahoo_news_updated_at', Time.now)
@celebrity.update_column('yahoo_news_rating', @celebrity.calc_yahoo_rating("news"))
end
end
respond_to do |format|
format.html { redirect_to :back, :notice => 'Mise à jour effectuée' }
end
end
match '/admin/update_global_rating_news', :controller => 'bc_admin', :action => 'update_global_rating_news'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment