'Return the size in bytes of this history by summing the \'total_size\'s of
all non-purged, unique datasets within it.'

@hybrid.hybrid_property
def disk_size(self):

    db_session = object_session(self)
    rval = db_session.query(func.sum(db_session.query(HistoryDatasetAssociation.dataset_id, Dataset.total_size).join(Dataset).filter((HistoryDatasetAssociation.table.c.history_id == self.id)).filter((HistoryDatasetAssociation.purged != true())).filter((Dataset.purged != true())).distinct().subquery().c.total_size)).first()[0]
    if (rval is None):
        rval = 0
    return rval
