pipeline.inc in Opigno TinCan API 7
Implements functions to progressively build a pipeline for mongoDB aggregate function
File
modules/opigno_tincan_api_stats/includes/model/pipeline.incView source
<?php
/**
* @file
* Implements functions to progressively build a pipeline for mongoDB aggregate function
*/
/**
* Create a valid empty pipeline
*
* @return array
* A structured pipeline array.
*/
function opigno_lrs_stats_query_new_pipeline() {
return array(
array(
'$match' => new stdClass(),
),
);
}
/**
* Set pipeline to retrieve only statements which match provided predicates
*
* @param array $pipeline
* A structured pipeline array.
*
* @param array $predicates
* A structured $predicates array.
*
* @return array
* A structured pipeline array.
*
*/
function opigno_lrs_stats_query_match($pipeline, $predicates) {
$pipeline[]['$match'] = $predicates;
return $pipeline;
}
/**
* Set pipeline to retrieve only a fixed number of statements
*
* @param array $pipeline
* A structured pipeline array.
*
* @param int $limit
*
* @return array
* A structured pipeline array.
*
*/
function opigno_lrs_stats_query_limit($pipeline, $limit) {
$pipeline[]['$limit'] = $limit;
return $pipeline;
}
/**
* Unwind array by path
*
* @param $pipeline
* A structured pipeline array.
*
* @param $path
*
* @return array
*/
function opigno_lrs_stats_query_unwind($pipeline, $path) {
$pipeline[]['$unwind'] = $path;
return $pipeline;
}
Functions
Name | Description |
---|---|
opigno_lrs_stats_query_limit | Set pipeline to retrieve only a fixed number of statements |
opigno_lrs_stats_query_match | Set pipeline to retrieve only statements which match provided predicates |
opigno_lrs_stats_query_new_pipeline | Create a valid empty pipeline |
opigno_lrs_stats_query_unwind | Unwind array by path |