/// Read all version entities pointing to the specified deployment IDs and
/// determine whether they are current or pending in order to produce
/// `SubgraphVersionSummary`s.
///
/// Returns the version summaries and a sequence of `AbortUnless`
/// `EntityOperation`s, which will abort the transaction if the version
/// summaries are out of date by the time the entity operations are applied.
Read all version entities pointing to the specified deployment IDs and
determine whether they are current or pending in order to produce
`SubgraphVersionSummary`s.

Returns the version summaries and a sequence of `AbortUnless`
`EntityOperation`s, which will abort the transaction if the version
summaries are out of date by the time the entity operations are applied.
Read all version entities pointing to the specified deployment IDs and determine whether they are current or pending in order to produce ` SubgraphVersionSummary ` s . Returns the version summaries and a sequence of ` AbortUnless ` ` EntityOperation ` s which will abort the transaction if the version summaries are out of date by the time the entity operations are applied .
fn read_subgraph_version_summaries(
        &self,
        deployment_ids: Vec<SubgraphDeploymentId>,
    ) -> Result<(Vec<SubgraphVersionSummary>, Vec<EntityOperation>), Error> {
        let version_filter = EntityFilter::new_in(
            "deployment",
            deployment_ids.iter().map(|id| id.to_string()).collect(),
        );
        let mut ops = vec![];
        let versions = self.find(SubgraphVersionEntity::query().filter(version_filter.clone()))?;
        let version_ids = versions
            .iter()
            .map(|version_entity| version_entity.id().unwrap())
            .collect::<Vec<_>>();
        ops.push(EntityOperation::AbortUnless {
            description: "Same set of subgraph versions must match filter".to_owned(),
            query: SubgraphVersionEntity::query().filter(version_filter),
            entity_ids: version_ids.clone(),
        });
        // Find subgraphs with one of these versions as current or pending
        let subgraphs_with_version_as_current_or_pending =
            self.find(SubgraphEntity::query().filter(EntityFilter::Or(vec![
                EntityFilter::new_in("currentVersion", version_ids.clone()),
                EntityFilter::new_in("pendingVersion", version_ids.clone()),
            ])))?;
        let subgraph_ids_with_version_as_current_or_pending =
            subgraphs_with_version_as_current_or_pending
                .iter()
                .map(|subgraph_entity| subgraph_entity.id().unwrap())
                .collect::<HashSet<_>>();
        ops.push(EntityOperation::AbortUnless {
            description: "Same set of subgraphs must have these versions as current or pending"
                .to_owned(),
            query: SubgraphEntity::query().filter(EntityFilter::Or(vec![
                EntityFilter::new_in("currentVersion", version_ids.clone()),
                EntityFilter::new_in("pendingVersion", version_ids),
            ])),
            entity_ids: subgraph_ids_with_version_as_current_or_pending
                .into_iter()
                .collect(),
        });
        // Produce summaries, deriving flags from information in subgraph entities
        let version_summaries =
            versions
                .into_iter()
                .map(|version_entity| {
                    let version_entity_id = version_entity.id().unwrap();
                    let version_entity_id_value = Value::String(version_entity_id.clone());
                    let subgraph_id = version_entity
                        .get("subgraph")
                        .unwrap()
                        .to_owned()
                        .as_string()
                        .unwrap();
                    let is_current = subgraphs_with_version_as_current_or_pending.iter().any(
                        |subgraph_entity| {
                            if subgraph_entity.get("currentVersion")
                                == Some(&version_entity_id_value)
                            {
                                assert_eq!(subgraph_entity.id().unwrap(), subgraph_id);
                                true
                            } else {
                                false
                            }
                        },
                    );
                    let is_pending = subgraphs_with_version_as_current_or_pending.iter().any(
                        |subgraph_entity| {
                            if subgraph_entity.get("pendingVersion")
                                == Some(&version_entity_id_value)
                            {
                                assert_eq!(subgraph_entity.id().unwrap(), subgraph_id);
                                true
                            } else {
                                false
                            }
                        },
                    );
                    SubgraphVersionSummary {
                        id: version_entity_id,
                        subgraph_id,
                        deployment_id: SubgraphDeploymentId::new(
                            version_entity
                                .get("deployment")
                                .unwrap()
                                .to_owned()
                                .as_string()
                                .unwrap(),
                        )
                        .unwrap(),
                        current: is_current,
                        pending: is_pending,
                    }
                })
                .collect();
        Ok((version_summaries, ops))
    }
fn read_subgraph_version_summaries ( & self , deployment_ids : Vec < SubgraphDeploymentId > , ) -> Result < ( Vec < SubgraphVersionSummary > , Vec < EntityOperation > ) , Error > { let version_filter = EntityFilter :: new_in ( " " , deployment_ids . iter ( ) . map ( | id | id . to_string ( ) ) . collect ( ) , ) ; let mut ops = vec ! [ ] ; let versions = self . find ( SubgraphVersionEntity :: query ( ) . filter ( version_filter . clone ( ) ) ) ? ; let version_ids = versions . iter ( ) . map ( | version_entity | version_entity . id ( ) . unwrap ( ) ) . collect :: < Vec < _ > > ( ) ; ops . push ( EntityOperation :: AbortUnless { description : " " . to_owned ( ) , query : SubgraphVersionEntity :: query ( ) . filter ( version_filter ) , entity_ids : version_ids . clone ( ) , } ) ; // Find subgraphs with one of these versions as current or pending let subgraphs_with_version_as_current_or_pending = self . find ( SubgraphEntity :: query ( ) . filter ( EntityFilter :: Or ( vec ! [ EntityFilter new_in ( " " version_ids clone ( ) ) EntityFilter new_in ( " " version_ids clone ( ) ) ] ) ) ) ? ; let subgraph_ids_with_version_as_current_or_pending = subgraphs_with_version_as_current_or_pending . iter ( ) . map ( | subgraph_entity | subgraph_entity . id ( ) . unwrap ( ) ) . collect :: < HashSet < _ > > ( ) ; ops . push ( EntityOperation :: AbortUnless { description : " " . to_owned ( ) , query : SubgraphEntity :: query ( ) . filter ( EntityFilter :: Or ( vec ! [ EntityFilter new_in ( " " version_ids clone ( ) ) EntityFilter new_in ( " " version_ids ) ] ) ) , entity_ids : subgraph_ids_with_version_as_current_or_pending . into_iter ( ) . collect ( ) , } ) ; // Produce summaries, deriving flags from information in subgraph entities let version_summaries = versions . into_iter ( ) . map ( | version_entity | { let version_entity_id = version_entity . id ( ) . unwrap ( ) ; let version_entity_id_value = Value :: String ( version_entity_id . clone ( ) ) ; let subgraph_id = version_entity . get ( " " ) . unwrap ( ) . to_owned ( ) . as_string ( ) . unwrap ( ) ; let is_current = subgraphs_with_version_as_current_or_pending . iter ( ) . any ( | subgraph_entity | { if subgraph_entity . get ( " " ) == Some ( & version_entity_id_value ) { assert_eq ! ( subgraph_entity id ( ) unwrap ( ) subgraph_id ) ; true } else { false } } , ) ; let is_pending = subgraphs_with_version_as_current_or_pending . iter ( ) . any ( | subgraph_entity | { if subgraph_entity . get ( " " ) == Some ( & version_entity_id_value ) { assert_eq ! ( subgraph_entity id ( ) unwrap ( ) subgraph_id ) ; true } else { false } } , ) ; SubgraphVersionSummary { id : version_entity_id , subgraph_id , deployment_id : SubgraphDeploymentId :: new ( version_entity . get ( " " ) . unwrap ( ) . to_owned ( ) . as_string ( ) . unwrap ( ) , ) . unwrap ( ) , current : is_current , pending : is_pending , } } ) . collect ( ) ; Ok ( ( version_summaries , ops ) ) }
Read all version entities pointing to the specified deployment IDs and
determine whether they are current or pending in order to produce
`SubgraphVersionSummary`s.
Read all version entities pointing to the specified deployment IDs and determine whether they are current or pending in order to produce ` SubgraphVersionSummary ` s .
&self
deployment_ids
Vec<SubgraphDeploymentId>