def METHOD_NAME(db):
    tn = baker.make("search.TransactionSearch", transaction_id=1, action_date="1900-01-01")
    a = baker.make(
        "references.Agency",
        id=1,
        toptier_agency__name="Really Old Agency That Shouldn't Show Up In Any Results",
        toptier_agency__toptier_code="ROATSSUIAR",
        subtier_agency__name="ROATSSUIAR subtier",
        _fill_optional=True,
    )
    baker.make(
        "search.AwardSearch",
        award_id=1,
        awarding_agency_id=a.id,
        funding_agency_id=a.id,
        latest_transaction_id=tn.transaction_id,
        certified_date=tn.action_date,
    )
    tn = baker.make("search.TransactionSearch", transaction_id=2, action_date="2020-01-01")
    a = baker.make(
        "references.Agency",
        id=2,
        toptier_agency__name="Agency With No Subtier That Shouldn't Show Up In Any Results",
        toptier_agency__toptier_code="AWNSTSSUIAR",
        subtier_agency=None,
        _fill_optional=True,
    )
    baker.make(
        "search.AwardSearch",
        award_id=2,
        awarding_agency_id=a.id,
        funding_agency_id=a.id,
        latest_transaction_id=tn.transaction_id,
        certified_date=tn.action_date,
    )
    a = baker.make(
        "references.Agency",
        id=3,
        toptier_agency__name="Lunar Colonization Society",
        toptier_agency__toptier_code="LCS123",
        subtier_agency__name="Darkside Chapter",
        _fill_optional=True,
    )
    baker.make(
        "search.AwardSearch",
        award_id=3,
        awarding_agency_id=a.id,
        funding_agency_id=a.id,
        latest_transaction_id=tn.transaction_id,
        certified_date=tn.action_date,
    )
    a = baker.make(
        "references.Agency",
        id=4,
        toptier_agency__name="Cerean Mineral Extraction Corp.",
        toptier_agency__toptier_code="CMEC",
        subtier_agency__name="Copper Division",
        _fill_optional=True,
    )
    baker.make(
        "search.AwardSearch",
        award_id=4,
        awarding_agency_id=a.id,
        funding_agency_id=a.id,
        latest_transaction_id=tn.transaction_id,
        certified_date=tn.action_date,
    )
    a = baker.make(
        "references.Agency",
        id=5,
        toptier_agency__name="Department of Transportation",
        subtier_agency__name="Department of Transportation",
        toptier_flag=True,
        _fill_optional=True,
    )
    baker.make(
        "search.AwardSearch",
        award_id=5,
        awarding_agency_id=a.id,
        funding_agency_id=a.id,
        latest_transaction_id=tn.transaction_id,
        certified_date=tn.action_date,
    )
    a = baker.make(
        "references.Agency",
        id=6,
        toptier_agency__name="Department of Defense",
        subtier_agency__name="Department of the Army",
        subtier_agency__abbreviation="USA",
        toptier_flag=False,
        _fill_optional=True,
    )
    baker.make(
        "search.AwardSearch",
        award_id=6,
        awarding_agency_id=a.id,
        funding_agency_id=a.id,
        latest_transaction_id=tn.transaction_id,
        certified_date=tn.action_date,
    )