Skip to content

Instantly share code, notes, and snippets.

@jmchilton
Created June 10, 2014 19:59
Show Gist options
  • Save jmchilton/a1b4f0bd3ce7189c0caf to your computer and use it in GitHub Desktop.
Save jmchilton/a1b4f0bd3ce7189c0caf to your computer and use it in GitHub Desktop.
Examples of determining recent usage in dynamic destinations
import logging
log = logging.getLogger( __name__ )
from datetime import timedelta
def cool_runner( rule_helper, user_email ):
job_count = rule_helper.job_count(
for_user_email=user_email,
created_in_last=timedelta(days=10),
)
log.info(" job count is %s" % job_count )
runtime_seconds = rule_helper.sum_job_runtime(
for_user_email=user_email,
updated_in_last=timedelta(days=10),
for_job_states=[ "ok" ],
for_destination="local"
)
log.info("runtime_seconds is %s" % runtime_seconds)
return "local"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment