@target_required
    def SearchByRegexName(self, regex_name, stats=False, target_id=None):
        # Get the grep outputs and only unique values
        grep_outputs = self.db.session.query(
            models.GrepOutput.output).filter_by(
                name=regex_name,
                target_id=target_id).group_by(models.GrepOutput.output).all()
        grep_outputs = [i[0] for i in grep_outputs]
        # Get one transaction per match
        transaction_ids = []
        for grep_output in grep_outputs:
            transaction_ids.append(self.db.session.query(models.Transaction.id).join(
                models.Transaction.grep_outputs).filter(
                    models.GrepOutput.output == grep_output,
                    models.GrepOutput.target_id == target_id).limit(1).all()[0][0])
        # Calculate stats if needed
        if stats:
            # Calculate the total number of matches
            num_matched_transactions = self.db.session.query(models.Transaction).join(
                models.Transaction.grep_outputs).filter(
                    models.GrepOutput.name == regex_name,
                    models.GrepOutput.target_id == target_id).group_by(
                        models.Transaction).count()
            # Calculate total number of transactions in scope
            num_transactions_in_scope = self.db.session.query(models.Transaction).filter_by(
                scope=True,
                target_id=target_id).count()
            # Calculate matched percentage
            if int(num_transactions_in_scope):
                match_percent = int(
                    (num_matched_transactions / float(num_transactions_in_scope)) * 100)
            else:
                match_percent = 0
        else:
            match_percent = None
        return ([
            regex_name,
            [json.loads(i) for i in grep_outputs],
            transaction_ids,
            match_percent])
Arguments are passed like: page_<VIEW_NAME>=<PAGE_NUMBER>
dataset/ETHPy150Open owtf/owtf/framework/db/transaction_manager.py/TransactionManager.SearchByRegexName--crossover with--dataset/ETHPy150Open dpgaspar/Flask-AppBuilder/flask_appbuilder/filters.py/TemplateFilters.link_page_filter