Last active
August 29, 2015 13:56
-
-
Save yannvery/9113477 to your computer and use it in GitHub Desktop.
Update Global News Rating with an Admin 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
| 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 |
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 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 |
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
| 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