@staticmethod
    def _get_first_build(project_id, test_name_sha):
        first_test = TestCase.query.filter(
            TestCase.project_id == project_id,
            TestCase.name_sha == test_name_sha,
        ).order_by(TestCase.date_created.asc()).limit(1).first()

        if first_test is None:
            return None

        first_build = Build.query.options(
            joinedload('author'),
            joinedload('source'),
        ).filter(
            Build.id == first_test.job.build_id,
        ).first()
        return first_build
Test basic case.
dataset/ETHPy150Open dropbox/changes/changes/api/build_flaky_tests.py/BuildFlakyTestsAPIView._get_first_build--crossover with--dataset/ETHPy150Open twisted/twisted/twisted/test/test_randbytes.py/RandomBaseTests.test_normal