received_q = db.session.query(Thank).join(ThankReceivedByUser).filter(
    ThankReceivedByUser.receiver_id == user_id)
q = given_q.union(received_q).order_by(Thank.date_registered)
SQLAlchemy Flask filter query to combine results from two models