def METHOD_NAME(document_id):
    """Check that the first version of this document was created less than
    24h ago.
    """
    written_at = DBSession.query(
        HistoryMetaData.written_at.label('written_at')). \
        select_from(HistoryMetaData). \
        join(DocumentVersion,
             DocumentVersion.history_metadata_id == HistoryMetaData.id). \
        filter(DocumentVersion.document_id == document_id). \
        order_by(asc(HistoryMetaData.written_at)).limit(1).scalar()
    return datetime.now(timezone.utc) - written_at <= timedelta(hours=24)