'The number of userless histories and associated datasets that have not been updated for the specified number of days.'

def userless_histories(self, trans, **kwd):

    params = util.Params(kwd)
    message = ''
    if params.userless_histories_days:
        userless_histories_days = int(params.userless_histories_days)
        cutoff_time = (datetime.utcnow() - timedelta(days=userless_histories_days))
        history_count = 0
        dataset_count = 0
        for history in trans.sa_session.query(model.History).filter(and_((model.History.table.c.user_id == null()), (model.History.table.c.deleted == true()), (model.History.table.c.update_time < cutoff_time))):
            for dataset in history.datasets:
                if (not dataset.deleted):
                    dataset_count += 1
            history_count += 1
        message = ('%d    userless    histories    (    including    a    total    of    %d    datasets    )    have    not    been    updated    for    at    least    %d    days.' % (history_count, dataset_count, userless_histories_days))
    else:
        message = 'Enter    the    number    of    days.'
    return (str(userless_histories_days), message)
