Simplify _get_last_action

There is no need to perform several queries.