Example #1
0
def storeResultEntry(user, key, ts, reading):
  logging.debug("storing result entry %s for user %s, key %s at timestamp %s" % (reading, user, key, ts))
  response = None

  # Sometimes timestamp comes in as a float, represented as seconds.[somethign else]; truncate digits after the
  # decimal
  ts = int(ts)
  currEntry = createEntry(user, key, ts, reading)

  try:
    response = get_result_stats_db().insert(currEntry)
  except Exception as e:
    logging.debug("failed to store result entry %s for user %s, key %s at timestamp %s" % (reading, user, key, ts))
    logging.debug("exception was: %s" % (e))
    get_result_stats_db_backup().insert(currEntry)

  # Return boolean that tells you whether the insertion was successful or not
  return response != None
Example #2
0
def storeResultEntry(user, key, ts, reading):
  logging.debug("storing result entry %s for user %s, key %s at timestamp %s" % (reading, user, key, ts))
  response = None

  # Sometimes timestamp comes in as a float, represented as seconds.[somethign else]; truncate digits after the
  # decimal
  ts = int(ts)
  currEntry = createEntry(user, key, ts, reading)

  try:
    response = get_result_stats_db().insert(currEntry)
  except Exception as e:
    logging.debug("failed to store result entry %s for user %s, key %s at timestamp %s" % (reading, user, key, ts))
    logging.debug("exception was: %s" % (e))
    get_result_stats_db_backup().insert(currEntry)

  # Return boolean that tells you whether the insertion was successful or not
  return response != None
def export_result_stats():
    entries = list(get_result_stats_db_backup().find())
    fname = "result_stats.csv"
    headers = ["stat", "_id", "reading", "ts", "user"]

    write_stats(fname, headers, entries)
                          }})
 logging.debug("Resetting alternatives...")
 reset_collection(edb.get_alternatives_db(), user.uuid, new_uuid)
 logging.debug("Resetting analysis...")
 reset_collection(edb.get_analysis_timeseries_db(), user.uuid,
                  new_uuid)
 logging.debug("Resetting client...")
 reset_collection(edb.get_client_db(), user.uuid, new_uuid)
 logging.debug("Resetting client_stats_backup...")
 reset_collection(edb.get_client_stats_db_backup(), user.uuid,
                  new_uuid)
 logging.debug("Resetting server_stats_backup...")
 reset_collection(edb.get_server_stats_db_backup(), user.uuid,
                  new_uuid)
 logging.debug("Resetting result_stats_backup...")
 reset_collection(edb.get_result_stats_db_backup(), user.uuid,
                  new_uuid)
 logging.debug("Resetting edb.get_common_place_db...")
 reset_collection(edb.get_common_place_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_common_trip_db...")
 reset_collection(edb.get_common_trip_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_habitica_db...")
 reset_collection(edb.get_habitica_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_pipeline_state_db...")
 reset_collection(edb.get_pipeline_state_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_profile_db...")
 reset_collection(edb.get_profile_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_timeseries_db...")
 reset_collection(edb.get_timeseries_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_timeseries_error_db...")
 reset_collection(edb.get_timeseries_error_db(), user.uuid,
Example #5
0
 new_uuid = uuid.uuid4()
 logging.debug("Mapping %s -> %s" % (new_uuid, user.uuid))
 edb.get_uuid_db().update({"uuid" : user.uuid},
                          {"$set": {"uuid" : new_uuid}})
 logging.debug("Resetting alternatives...")
 reset_collection(edb.get_alternatives_db(), user.uuid, new_uuid)
 logging.debug("Resetting analysis...")
 reset_collection(edb.get_analysis_timeseries_db(), user.uuid, new_uuid)
 logging.debug("Resetting client...")
 reset_collection(edb.get_client_db(), user.uuid, new_uuid)
 logging.debug("Resetting client_stats_backup...")
 reset_collection(edb.get_client_stats_db_backup(), user.uuid, new_uuid)
 logging.debug("Resetting server_stats_backup...")
 reset_collection(edb.get_server_stats_db_backup(), user.uuid, new_uuid)
 logging.debug("Resetting result_stats_backup...")
 reset_collection(edb.get_result_stats_db_backup(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_common_place_db...")
 reset_collection(edb.get_common_place_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_common_trip_db...")
 reset_collection(edb.get_common_trip_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_habitica_db...")
 reset_collection(edb.get_habitica_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_pipeline_state_db...")
 reset_collection(edb.get_pipeline_state_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_profile_db...")
 reset_collection(edb.get_profile_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_timeseries_db...")
 reset_collection(edb.get_timeseries_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_timeseries_error_db...")
 reset_collection(edb.get_timeseries_error_db(), user.uuid, new_uuid)
 logging.debug("Resetting edb.get_usercache_db...")
def export_result_stats():
	entries = list(get_result_stats_db_backup().find())
	fname = "result_stats.csv"
	headers = ['stat', '_id', 'reading', 'ts', 'user']

	write_stats(fname, headers, entries)