def _check_round_trip_reminder(self, card, last_state=None):
        """ Checks products for remaining round trips that have fallen below threshold """
        remind = False
        threshold = int(self.threshold)

        for product in card.products:
            if product.remaining_rides is None:
                continue

            try:
                # This does take into consideration half trips
                round_trips = product.remaining_rides / 2.0
                should_remind = round_trips < threshold

                # Pedantic - check last state products for name match
                # and number of round trips
                if last_state:
                    last_trips = None

                    # Find a matching product to compare
                    for last in last_state.products:
                        if last.name != product.name or last.remaining_rides is None:
                            continue
                        last_trips = last.remaining_rides / 2.0
                        break

                    if last_trips is not None:
                        pedantic_remind = last_trips != round_trips and should_remind

                        app.logger.info('Ensuring a change in %s round trips for %s: %s' % (round_trips, product.name, pedantic_remind))
                        remind = remind or pedantic_remind
                        continue

                # The default case
                remind = remind or should_remind
            except:
                app.logger.exception('Exception checking round trips')
                pass

        return remind
dataset/ETHPy150Open shaunduncan/breezeminder/breezeminder/models/reminder.py/Reminder._check_round_trip_reminder/original