Calculate the status of a run.

        :param dict target_freshness: The target freshness dictionary. It must
            match the freshness spec.
        :param timedelta freshness: The actual freshness of the data, as
            calculated from the database's timestamps

def _calculate_status(self, target_freshness, freshness):
        """Calculate the status of a run.

        :param dict target_freshness: The target freshness dictionary. It must
            match the freshness spec.
        :param timedelta freshness: The actual freshness of the data, as
            calculated from the database's timestamps
        """
        # if freshness > warn_after > error_after, you'll get an error, not a
        # warning
        for key in ('error', 'warn'):
            fullkey = '{}_after'.format(key)
            if fullkey not in target_freshness:
                continue

            target = target_freshness[fullkey]
            kwname = target['period'] + 's'
            kwargs = {kwname: target['count']}
            if freshness > timedelta(**kwargs).total_seconds():
                return key
        return 'pass'