Skip to content

Commit 7a285f6

Browse files
authored
Merge pull request #117 from catalyst/issue100
issue #100: add filters for rules table
2 parents b3e4e2f + badbf47 commit 7a285f6

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

classes/reportbuilder/local/entities/rule_entity.php

+57
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
namespace tool_dynamic_cohorts\reportbuilder\local\entities;
1818

1919
use core_reportbuilder\local\entities\base;
20+
use core_reportbuilder\local\filters\boolean_select;
21+
use core_reportbuilder\local\filters\text;
2022
use core_reportbuilder\local\report\column;
23+
use core_reportbuilder\local\report\filter;
2124
use lang_string;
2225
use tool_dynamic_cohorts\rule;
2326

@@ -57,6 +60,10 @@ public function initialise(): base {
5760
$this->add_column($column);
5861
}
5962

63+
foreach ($this->get_all_filters() as $filter) {
64+
$this->add_filter($filter);
65+
}
66+
6067
return $this;
6168
}
6269

@@ -174,4 +181,54 @@ protected function get_all_columns(): array {
174181

175182
return $columns;
176183
}
184+
185+
/**
186+
* Return list of all available filters
187+
*
188+
* @return filter[]
189+
*/
190+
protected function get_all_filters(): array {
191+
$tablealias = $this->get_table_alias('tool_dynamic_cohorts');
192+
193+
// Name filter.
194+
$filters[] = (new filter(
195+
text::class,
196+
'name',
197+
new lang_string('name', 'core_cohort'),
198+
$this->get_entity_name(),
199+
"{$tablealias}.name"
200+
))
201+
->add_joins($this->get_joins());
202+
203+
// Bulk processing filter.
204+
$filters[] = (new filter(
205+
boolean_select::class,
206+
'bulkprocessing',
207+
new lang_string('rule_entity.bulkprocessing', 'tool_dynamic_cohorts'),
208+
$this->get_entity_name(),
209+
"{$tablealias}.bulkprocessing"
210+
))
211+
->add_joins($this->get_joins());
212+
213+
// Broken filter.
214+
$filters[] = (new filter(
215+
boolean_select::class,
216+
'broken',
217+
new lang_string('broken', 'tool_dynamic_cohorts'),
218+
$this->get_entity_name(),
219+
"{$tablealias}.broken"
220+
))
221+
->add_joins($this->get_joins());
222+
223+
// Enabled filter.
224+
$filters[] = (new filter(
225+
boolean_select::class,
226+
'enabled',
227+
new lang_string('enabled', 'tool_dynamic_cohorts'),
228+
$this->get_entity_name(),
229+
"{$tablealias}.enabled"
230+
))
231+
->add_joins($this->get_joins());
232+
return $filters;
233+
}
177234
}

classes/reportbuilder/local/systemreports/rules.php

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ protected function initialise(): void {
114114
$cohortentity->get_column('name')
115115
->set_title(new lang_string('cohort', 'tool_dynamic_cohorts'));
116116

117+
$this->add_filter_from_entity('rule_entity:name');
118+
$this->add_filter_from_entity('rule_entity:bulkprocessing');
119+
$this->add_filter_from_entity('rule_entity:broken');
120+
$this->add_filter_from_entity('rule_entity:enabled');
121+
117122
$this->set_initial_sort_column('rule_entity:name', SORT_ASC);
118123
}
119124

lang/en/tool_dynamic_cohorts.php

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
$string['any'] = 'Any';
3333
$string['backtolistofrules'] = 'Back to the list of rules';
3434
$string['before'] = 'Before';
35+
$string['broken'] = 'Broken';
3536
$string['brokenruleswarning'] = 'There are some broken rules require your attention. <br /> To fix a broken rule you should remove all broken conditions. <br />Sometimes a rule becomes broken when matching users SQL failed. In this case all condition are ok, but the rule is marked as broken. You should check Moodle logs for "Matching users failed" event and related SQL errors. <br />Please note, that in any case you have to re-save the rule to mark it as unbroken.';
3637
$string['bulkprocessing'] = 'Bulk processing';
3738
$string['bulkprocessing_help'] = 'If this option is enabled, users will be added and removed from cohort in bulk. This will significantly improve processing performance. However, using this option will suppress triggering events when users added or removed from cohort.';

version.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'tool_dynamic_cohorts';
28-
$plugin->release = 2024110701;
29-
$plugin->version = 2024110701;
28+
$plugin->release = 2024112100;
29+
$plugin->version = 2024112100;
3030
$plugin->requires = 2022112800;
3131
$plugin->supported = [404, 405];
3232
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)