@@ -40,6 +40,7 @@ def initialize(similar_system)
40
40
@efficiency = nil
41
41
end
42
42
43
+ # TODO: fix me!
43
44
# @return output_pa divided by system_watts (Wh).
44
45
def output_per_system_watts
45
46
output = self . output_pa / self . system_watts . to_i
@@ -92,6 +93,7 @@ def self.find_similar_system(pvo_search_params)
92
93
top5 . each do |system |
93
94
# get rid of systems with secondary panels
94
95
if system [ 'entries' ] . to_i >= 100 && system [ 'panel_count' ] == 'NaN'
96
+ # returning nil here in spec
95
97
system_info = self . get_system ( system [ 'id' ] )
96
98
if system_info [ 'shade' ] == 'No'
97
99
similar_system = system_info . merge ( system )
@@ -111,9 +113,12 @@ def self.find_similar_system(pvo_search_params)
111
113
# @return [Array<Hash>] of systems [{name: 'some_name', size: 'size,...}, {...}]
112
114
# or empty array.
113
115
def self . search ( query )
114
- params = { 'q' => query ,
115
- 'country' => 'Australia' }
116
- response = self . request ( 'search' , params )
116
+ params = { :q => query ,
117
+ :country => 'Australia' }
118
+ request = PvOutputWrapper ::Request . new ( Rails . application . secrets . pvo_api_key ,
119
+ Rails . application . secrets . pvo_system_id )
120
+ response = request . search ( params ) . body
121
+ # response = self.request('search', params)
117
122
response . chomp!
118
123
results = [ ]
119
124
keys = [ 'name' , 'system_watts' , 'postcode' , 'orientation' , 'entries' , 'last_entry' , 'id' , 'panel' , 'inverter' , 'distance' , 'latitude' , 'longitude' ]
@@ -133,6 +138,7 @@ def self.search(query)
133
138
end
134
139
135
140
# @param [Fixnum]
141
+ # TODO handle nil/empty resultset
136
142
# @return [Hash] of system info data.
137
143
def self . get_system ( id )
138
144
response = self . request ( 'getsystem' , { :sid1 => id } )
0 commit comments