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

Method group_lt_op

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

Source from the content-addressed store, hash-verified

222 }
223
224 fn group_lt_op(
225 &self,
226 other: &Box<dyn Value>,
227 group_op: &GroupComparisonOperator,
228 ) -> Result<Box<dyn Value>, String> {
229 if other.is_array_of(|element_type| element_type.is_date()) {
230 let elements = &other.as_array().unwrap();
231 let mut matches_count = 0;
232 for element in elements.iter() {
233 if self.timestamp < element.as_date().unwrap() {
234 matches_count += 1;
235 if GroupComparisonOperator::Any.eq(group_op) {
236 break;
237 }
238 }
239 }
240
241 let result = match group_op {
242 GroupComparisonOperator::All => matches_count == elements.len(),
243 GroupComparisonOperator::Any => matches_count > 0,
244 };
245
246 return Ok(Box::new(BoolValue::new(result)));
247 }
248 Err("Unexpected type to perform `<` with".to_string())
249 }
250
251 fn lte_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> {
252 if let Some(other_text) = other.as_any().downcast_ref::<DateValue>() {

Callers 1

Calls 6

is_array_ofMethod · 0.80
as_arrayMethod · 0.80
as_dateMethod · 0.80
is_dateMethod · 0.45
eqMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected