• R/O
  • HTTP
  • SSH
  • HTTPS

pettanr: コミット

サーバ側、Railsシステム本体


コミットメタ情報

リビジョン964c3e1a9103cb585c816bc2fc630bfa8d8e6cf0 (tree)
日時2013-01-21 11:33:36
作者yasushiito <yas@pen-...>
コミッターyasushiito

ログメッセージ

t#30487:fix export error

変更サマリ

差分

--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -108,8 +108,13 @@ class ApplicationController < ActionController::Base
108108 end
109109
110110 def export_from_provider url
111- json = RestClient.get url
112- JSON.parse json
111+ res = nil
112+ begin
113+ json = RestClient.get url
114+ res = JSON.parse json
115+ rescue
116+ end
117+ res
113118 end
114119
115120 def export_by action, provider_status, ymd
--- a/app/controllers/provider_statuses_controller.rb
+++ b/app/controllers/provider_statuses_controller.rb
@@ -1,7 +1,31 @@
11 class ProviderStatusesController < ApplicationController
22 layout 'test' if MagicNumber['test_layout']
33 before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import]
4-
4+
5+ private
6+
7+ def licenses_port
8+ licenses = export_by('licenses_export', @provider_status, params[:date])
9+ return nil unless licenses
10+ ProviderLicense.import @provider_status.provider.id, licenses
11+ end
12+
13+ def artists_port
14+ artists = export_by('artists_export', @provider_status, params[:date])
15+ return nil unless artists
16+ ProviderArtist.import @provider_status.provider.id, artists
17+ end
18+
19+ def original_pictures_port
20+ original_pictures = export_by('original_pictures_export', @provider_status, params[:date])
21+ return nil unless original_pictures
22+ pictures = export_by('pictures_export', @provider_status, params[:date])
23+ return nil unless pictures
24+ ProviderOriginalPicture.import @provider_status.provider.id, original_pictures, pictures
25+ end
26+
27+ public
28+
529 def index
630 @page = ProviderStatus.page params[:page]
731 @page_size = ProviderStatus.page_size params[:page_size]
@@ -69,9 +93,7 @@ class ProviderStatusesController < ApplicationController
6993 def licenses_import
7094 @provider_status = ProviderStatus.show(params[:id], @admin)
7195 raise ActiveRecord::Forbidden if @provider_status.status == 0
72- t = ymd_to_time params[:date]
73- url = export_url @provider_status.provider.demander_url, 'licenses_export', @provider_status.token, t
74- @failures = ProviderLicense.import @provider_status.provider.id, export_from_provider(url)
96+ @failures = licenses_port
7597 respond_to do |format|
7698 format.html # show.html.erb
7799 format.json { render :json => @failures.to_json() }
@@ -81,9 +103,7 @@ class ProviderStatusesController < ApplicationController
81103 def artists_import
82104 @provider_status = ProviderStatus.show(params[:id], @admin)
83105 raise ActiveRecord::Forbidden if @provider_status.status == 0
84- t = ymd_to_time params[:date]
85- url = export_url @provider_status.provider.demander_url, 'artists_export', @provider_status.token, t
86- @failures = ProviderArtist.import @provider_status.provider.id, export_from_provider(url)
106+ @failures = artists_port
87107 respond_to do |format|
88108 format.html # show.html.erb
89109 format.json { render :json => @failures.to_json() }
@@ -93,9 +113,7 @@ class ProviderStatusesController < ApplicationController
93113 def original_pictures_import
94114 @provider_status = ProviderStatus.show(params[:id], @admin)
95115 raise ActiveRecord::Forbidden if @provider_status.status == 0
96- original_pictures = export_by('original_pictures_export', @provider_status, params[:date])
97- pictures = export_by('pictures_export', @provider_status, params[:date])
98- @failures = ProviderOriginalPicture.import @provider_status.provider.id, original_pictures, pictures
116+ @failures = original_pictures_port
99117 respond_to do |format|
100118 format.html # show.html.erb
101119 format.json { render :json => @failures.to_json() }
--- a/app/views/provider_statuses/artists_import.html.erb
+++ b/app/views/provider_statuses/artists_import.html.erb
@@ -1,7 +1,9 @@
11 <h1><%= t('.title') %></h1>
22 <p id="notice"><%= notice %></p>
33
4-<% if @failures.empty? %>
4+<% if @failures == nil %>
5+ <h1>No Response</h1>
6+<% elsif @failures.empty? %>
57 <h2>
68 <%= t('provider_statuses.artists_import.success') %>
79 </h2>
--- a/app/views/provider_statuses/licenses_import.html.erb
+++ b/app/views/provider_statuses/licenses_import.html.erb
@@ -1,7 +1,9 @@
11 <h1><%= t('.title') %></h1>
22 <p id="notice"><%= notice %></p>
33
4-<% if @failures.empty? %>
4+<% if @failures == nil %>
5+ <h1>No Response</h1>
6+<% elsif @failures.empty? %>
57 <h2>
68 <%= t('provider_statuses.licenses_import.success') %>
79 </h2>
--- a/app/views/provider_statuses/original_pictures_import.html.erb
+++ b/app/views/provider_statuses/original_pictures_import.html.erb
@@ -1,7 +1,9 @@
11 <h1><%= t('.title') %></h1>
22 <p id="notice"><%= notice %></p>
33
4-<% if @failures[:original_pictures].any? %>
4+<% if @failures == nil %>
5+ <h1>No Response</h1>
6+<% elsif @failures[:original_pictures].any? %>
57 <h2>
68 <%= t('provider_statuses.original_pictures_import.fail', :size => @failures[:original_pictures].size) %>
79 </h2>
旧リポジトリブラウザで表示