'Get count of records created in the last x minutes'

def get_creation_count(self, doctype, minutes):

    from frappe.utils import now_datetime
    from dateutil.relativedelta import relativedelta
    return frappe.db.sql(u'select    count(name)    from    `tab{doctype}`\n DCTB  DCTB  DCTB where    creation    >=    %s'.format(doctype=doctype), (now_datetime() - relativedelta(minutes=minutes)))[0][0]
