Ejemplo n.º 1
0
  def query_to_table_row(self, query):
    metric_html = open('ui/html/metric.html').read()

    current_value = ''
    try:
      current_value = DataPoint.get_by_query_most_recent(query)[0].text
    except IndexError:
      current_value = 'None'

    metric_overview = self.get_overview(query)

    metric_data = {
      'query_id': query.key(), 
      'name': query.name, 
      'text': query.text, 
      'format': query.format, 
      'frequency': self.frequency_minutes_to_text(query.frequency),
      'lastsentat': query.lastSentAt,
      'freq_minutes': query.frequency,
      'current_value': current_value,
      'overview': metric_overview,
      'ask_when': json.dumps(query.ask_when),
    }

    return metric_html % metric_data
Ejemplo n.º 2
0
  def refresh_most_recent_dp(self, queries):
    for query in queries:
      most_recent_dp = DataPoint.get_by_query_most_recent(query)
      
      mck_most_recent_dp = str(query.key()) + '.most-recent-dp'
      mck_most_recent_dp_update = str(query.key()) + 'most-recent-dp-update'

      memcache.set(
        key=mck_most_recent_dp,
        value=most_recent_dp,
      )

      memcache.set(
        key=mck_most_recent_dp_update,  
        value=datetime.now().strftime('%s'),
      )

      logging.info('Updated Most Recent Datapoint for metric: ' + str(query.key()))