示例#1
0
def get_top_printed_count():
    try:
        kind_stats = stats.KindStat().all().filter(
            "kind_name =", "PrintedQuestionModel").get()
        count = kind_stats.count
    except Exception, ex:
        logging.error(ex)
        count = PrintedQuestionModel.all().count()
示例#2
0
  def create_kind_stat_entry(self, kind, size, number, timestamp):
    """ Puts a kind statistic into the datastore.
 
    Args:
      kind: The entity kind.
      size: An int representing the number of bytes taken by entity kind.
      number: The total number of entities.
      timestamp: A datetime.datetime object.
    Returns: 
      True on success, False otherwise.
    """
    kind_stat = stats.KindStat(kind_name=kind, 
                               bytes=size,
                               count=number,
                               timestamp=timestamp)
    try:
      db.put(kind_stat)
    except datastore_errors.InternalError, internal_error:
      logging.error("Error inserting kind stat: {0}.".format(internal_error))
      return False