def get_giving_for_profile(self):

        GIVING = """\

            SELECT * FROM (
                SELECT DISTINCT ON (pi.team)
                       pi.team  AS team_slug
                     , pi.amount
                     , pi.due
                     , pi.ctime
                     , pi.mtime
                     , t.name   AS team_name
                  FROM payment_instructions pi
                  JOIN teams t ON pi.team = t.slug
                 WHERE participant = %s
                   AND t.is_approved is true
                   AND t.is_closed is not true
              ORDER BY pi.team
                     , pi.mtime DESC
            ) AS foo
            ORDER BY amount DESC
                   , team_slug

        """
        giving = self.db.all(GIVING, (self.username,))


        # Compute the totals.
        # ==================

        totals = {
            'amount': sum([rec.amount for rec in giving]) or Decimal('0.00'),
            'due': sum([rec.due for rec in giving]) or Decimal('0.00')
        }

        return giving, totals
Function to clean a tier.
dataset/ETHPy150Open gratipay/gratipay.com/gratipay/models/participant.py/Participant.get_giving_for_profile--crossover with--dataset/ETHPy150Open cidles/poio-api/src/poioapi/io/odin.py/Parser._sanitize_line