<filename>goes_mongo_inserter/lib/update_latest_readings.py


def update_env_latest(db, config, data):
    """ Finds the latest value for each reading and stores the
        key, value, and timestamp
    """

    collection_name = "%s.env.latest" % config['station']
    collection = db[collection_name]

    state = {}
    for d in data:
        for key in d:
            key_parts = key.split('-')
            parameter = key_parts[0]
            if len(key_parts) > 1:
                units = key_parts[1]
            else:
                units = None

            state[key] = {
                'timestamp': d['timestamp'],
                'value': d[key],
                'parameter': parameter,
                'units': units
            }

    # Remove _id parameter before update
    del state['_id']

    collection.update({}, {'$set': state}, upsert=True)

<filename>goes_mongo_inserter/lib/update_latest_readings.py


def update_env_latest(db, config, data):
    """ Finds the latest value for each reading and stores the
        key, value, and timestamp
    """

    collection_name = "%s.env.latest" % config['station']
    collection = db[collection_name]

    state = {}
    for d in data:
        for key in d:
            key_parts = key.split('-')
            parameter = key_parts[0]
            if len(key_parts) > 1:
                units = key_parts[1]
            else:
                units = None

            state[key] = {
                'timestamp': d['timestamp'],
                'value': d[key],
                'parameter': parameter,
                'units': units
            }

    # Remove _id parameter before update
    del state['_id']

    collection.update({}, {'$set': state}, upsert=True)

Finds the latest value for each reading and stores the         key, value, and timestamp # Remove _id parameter before update