Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

--- develop ---

* issue#306: Match flows that start before and end after the report time window; flows are still read only from the partitions inside that window
* dev: Run the CI poller with the shared runner group so RRD files and structured directories pass permission verification
* issue: Remove the Listener and Stream from the report page. They are part of what a Filter materializes, so changing them there ran the report against data that was never materialized. They are now set only in the Filter editor, and the report page reads them straight from the saved Filter. The New button now follows Edit.

Expand Down
6 changes: 3 additions & 3 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2708,10 +2708,10 @@ function get_date_filter($sql_range, &$sql_range_params, $start, $end, int $rang

switch($range_type) {
case 1: // Any part in specified time span
$sql_range = '(`start_time` BETWEEN ? AND ? OR `end_time` BETWEEN ? AND ?)';
// Bind the window start first: the run statistics read the stored
// map_range_params as (start, end) for every range type.
$sql_range = '(`end_time` >= ? AND `start_time` <= ?)';

$sql_range_params[] = $date1;
$sql_range_params[] = $date2;
$sql_range_params[] = $date1;
$sql_range_params[] = $date2;

Expand Down
23 changes: 15 additions & 8 deletions tests/Unit/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,24 @@
expect($params)->toBe(array(16, '2001:db8::', '2001:db8::ffff:ffff:ffff:ffff'));
});

it('builds each supported temporal overlap contract', function ($rangeType, $expectedSql, $expectedCount) {
it('builds each supported temporal filter contract', function ($rangeType, $expectedSql, $expectedParams) {
$params = array();
$sql = get_date_filter('', $params, 1704067200, 1704070800, $rangeType);

expect($sql)->toBe($expectedSql)
->and($params)->toHaveCount($expectedCount)
->and($params[0])->toBe('2024-01-01 00:00:00')
->and($params[1])->toBe('2024-01-01 01:00:00');
->and($params)->toBe($expectedParams);
})->with(array(
array(1, '(`start_time` BETWEEN ? AND ? OR `end_time` BETWEEN ? AND ?)', 4),
array(2, '(`end_time` BETWEEN ? AND ?)', 2),
array(3, '(`start_time` BETWEEN ? AND ?)', 2),
array(4, '(`start_time` BETWEEN ? AND ? AND `end_time` BETWEEN ? AND ?)', 4),
array(1, '(`end_time` >= ? AND `start_time` <= ?)', array('2024-01-01 00:00:00', '2024-01-01 01:00:00')),
array(2, '(`end_time` BETWEEN ? AND ?)', array('2024-01-01 00:00:00', '2024-01-01 01:00:00')),
array(3, '(`start_time` BETWEEN ? AND ?)', array('2024-01-01 00:00:00', '2024-01-01 01:00:00')),
array(4, '(`start_time` BETWEEN ? AND ? AND `end_time` BETWEEN ? AND ?)', array('2024-01-01 00:00:00', '2024-01-01 01:00:00', '2024-01-01 00:00:00', '2024-01-01 01:00:00')),
));

it('stores every temporal filter with the window start and end first', function ($rangeType) {
// The run statistics query reads map_range_params[0] and [1] as the
// window bounds for the shard cache lookup.
$params = array();
get_date_filter('', $params, 1704067200, 1704070800, $rangeType);

expect(array_slice($params, 0, 2))->toBe(array('2024-01-01 00:00:00', '2024-01-01 01:00:00'));
})->with(array(1, 2, 3, 4));
Loading