def get_extra_attrs_from_db(self, item_list):
        result = {}
        job_id_to_steps = defaultdict(list)
        for step in item_list:
            job_id_to_steps[step.job_id].append(step)
        if job_id_to_steps:
            for jobplan in JobPlan.query.filter(JobPlan.job_id.in_(job_id_to_steps.keys())):
                for step in job_id_to_steps[jobplan.job_id]:
                    result[step] = {'jobplan': jobplan}

        # In theory, every JobStep should have a JobPlan, but we don't need to assume that
        # or enforce it in this method, and this method does need to be sure that each
        # step has an entry in result, so we make sure of that here.
        for step in item_list:
            if step not in result:
                result[step] = {'jobplan': None}

        return result
dataset/ETHPy150Open dropbox/changes/changes/api/serializer/models/jobstep.py/JobStepCrumbler.get_extra_attrs_from_db/original