Tabs to spaces and build a list with counts of increasing segments.
This commit is contained in:
		
							
								
								
									
										19
									
								
								pi_temp.py
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								pi_temp.py
									
									
									
									
									
								
							@@ -122,10 +122,29 @@ def history():
 | 
				
			|||||||
    fig = Figure(data=data, layout=layout)
 | 
					    fig = Figure(data=data, layout=layout)
 | 
				
			||||||
    graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
 | 
					    graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    x = time_series_temperature_values
 | 
				
			||||||
 | 
					    result = longest_streak(x)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return render_template("history.html",  timezone = timezone,
 | 
					    return render_template("history.html",  timezone = timezone,
 | 
				
			||||||
                                            graphJSON = graphJSON,
 | 
					                                            graphJSON = graphJSON,
 | 
				
			||||||
 | 
					                                            result = result,
 | 
				
			||||||
                                            )
 | 
					                                            )
 | 
				
			||||||
                                            
 | 
					                                            
 | 
				
			||||||
 | 
					def longest_streak(grades):
 | 
				
			||||||
 | 
					    if len(grades) < 2:
 | 
				
			||||||
 | 
					        return len(grades)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        start, streaks = -1, []
 | 
				
			||||||
 | 
					        for idx, (x, y) in enumerate(zip(grades, grades[1:])):
 | 
				
			||||||
 | 
					            if x > y:
 | 
				
			||||||
 | 
					                streaks.append(idx - start)
 | 
				
			||||||
 | 
					                start = idx
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            streaks.append(idx - start + 1) 
 | 
				
			||||||
 | 
					        long_streaks = [x for x in streaks if x > 3]
 | 
				
			||||||
 | 
					        return long_streaks
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
def get_records():
 | 
					def get_records():
 | 
				
			||||||
    from_date_str   = request.args.get('from',time.strftime("%Y-%m-%d 00:00")) #Get the from date value from the URL
 | 
					    from_date_str   = request.args.get('from',time.strftime("%Y-%m-%d 00:00")) #Get the from date value from the URL
 | 
				
			||||||
    to_date_str     = request.args.get('to',time.strftime("%Y-%m-%d %H:%M"))   #Get the to date value from the URL
 | 
					    to_date_str     = request.args.get('to',time.strftime("%Y-%m-%d %H:%M"))   #Get the to date value from the URL
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,6 +79,8 @@
 | 
				
			|||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div class='row' id='plotly-plot'></div>
 | 
					    <div class='row' id='plotly-plot'></div>
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    {{ result }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  </body>
 | 
					  </body>
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
  <footer>
 | 
					  <footer>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user