File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -143,10 +143,12 @@ def list(self, request):
143143 nodes = []
144144 # Loop through the last active nodes
145145 for last_active in LastActiveNodes .objects .iterator ():
146- # Get the current node
146+ # Get the current node only if it has public sensors
147147 node = Node .objects .filter (
148- Q (id = last_active .node .id ), ~ Q (sensors = None )
149- ).get ()
148+ Q (id = last_active .node .id ), Q (sensors__public = True )
149+ ).first ()
150+ if node is None :
151+ continue
150152
151153 # The last acive date
152154 last_data_received_at = last_active .last_data_received_at
@@ -161,7 +163,7 @@ def list(self, request):
161163 SensorDataValue .objects .filter (
162164 Q (sensordata__sensor__node = last_active .node .id ),
163165 # Open endpoints should return data from public sensors
164- # only.
166+ # only in case a node has both public & private sensors
165167 Q (sensordata__sensor__public = True ),
166168 Q (sensordata__location = last_active .location .id ),
167169 Q (sensordata__timestamp__gte = last_5_mins ),
@@ -214,6 +216,7 @@ def list(self, request):
214216 "stats" : stats ,
215217 }
216218 )
219+
217220 return Response (nodes )
218221
219222 def create (self , request ):
You can’t perform that action at this time.
0 commit comments