MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / group_lte_op

Method group_lte_op

crates/gitql-core/src/values/time.rs:232–257  ·  view source on GitHub ↗
(
        &self,
        other: &Box<dyn Value>,
        group_op: &GroupComparisonOperator,
    )

Source from the content-addressed store, hash-verified

230 }
231
232 fn group_lte_op(
233 &self,
234 other: &Box<dyn Value>,
235 group_op: &GroupComparisonOperator,
236 ) -> Result<Box<dyn Value>, String> {
237 if other.is_array_of(|element_type| element_type.is_time()) {
238 let elements = &other.as_array().unwrap();
239 let mut matches_count = 0;
240 for element in elements.iter() {
241 if self.value <= element.as_time().unwrap() {
242 matches_count += 1;
243 if GroupComparisonOperator::Any.eq(group_op) {
244 break;
245 }
246 }
247 }
248
249 let result = match group_op {
250 GroupComparisonOperator::All => matches_count == elements.len(),
251 GroupComparisonOperator::Any => matches_count > 0,
252 };
253
254 return Ok(Box::new(BoolValue::new(result)));
255 }
256 Err("Unexpected type to perform `<=` with".to_string())
257 }
258}

Callers

nothing calls this directly

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_timeMethod · 0.80
is_timeMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected