| 40 | } |
| 41 | |
| 42 | async fn test_root_sorting( |
| 43 | api: &DatabaseApi<'_>, |
| 44 | chunk_size: usize, |
| 45 | sort: impl IntoIterator<Item = (EntityQueryPath<'static>, Ordering, NullOrdering)> + Send, |
| 46 | expected_order: impl IntoIterator<Item = &PropertyObject> + Send, |
| 47 | ) { |
| 48 | let sorting_paths = sort |
| 49 | .into_iter() |
| 50 | .map(|(path, ordering, nulls)| EntityQuerySortingRecord { |
| 51 | path, |
| 52 | ordering, |
| 53 | nulls: Some(nulls), |
| 54 | }) |
| 55 | .collect::<Vec<_>>(); |
| 56 | let mut cursor = None; |
| 57 | |
| 58 | let mut found_entities = HashSet::new(); |
| 59 | let mut entities = Vec::new(); |
| 60 | |
| 61 | loop { |
| 62 | let QueryEntitySubgraphResponse { |
| 63 | mut subgraph, |
| 64 | cursor: new_cursor, |
| 65 | closed_multi_entity_types: _, |
| 66 | definitions: _, |
| 67 | entity_permissions: _, |
| 68 | } = Box::pin(api.query_entity_subgraph( |
| 69 | api.account_id, |
| 70 | QueryEntitySubgraphParams::Paths { |
| 71 | traversal_paths: Vec::new(), |
| 72 | request: QueryEntitiesParams { |
| 73 | filter: Filter::All(Vec::new()), |
| 74 | temporal_axes: QueryTemporalAxesUnresolved::live_only(), |
| 75 | sorting: EntityQuerySorting { |
| 76 | paths: sorting_paths.clone(), |
| 77 | cursor: Option::take(&mut cursor), |
| 78 | }, |
| 79 | limit: chunk_size, |
| 80 | conversions: Vec::new(), |
| 81 | include_entity_types: None, |
| 82 | include_drafts: false, |
| 83 | include_permissions: false, |
| 84 | }, |
| 85 | }, |
| 86 | )) |
| 87 | .await |
| 88 | .expect("could not get entity"); |
| 89 | let new_entities = subgraph |
| 90 | .roots |
| 91 | .into_iter() |
| 92 | .filter_map(|root| match root { |
| 93 | GraphElementVertexId::KnowledgeGraph(entity_vertex_id) => { |
| 94 | subgraph.vertices.entities.remove(&entity_vertex_id) |
| 95 | } |
| 96 | GraphElementVertexId::DataType(_) |
| 97 | | GraphElementVertexId::PropertyType(_) |
| 98 | | GraphElementVertexId::EntityType(_) => unreachable!(), |
| 99 | }) |