Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 103... Línea 103...
103
            new lang_string('name'),
103
            new lang_string('name'),
104
            $this->get_entity_name()
104
            $this->get_entity_name()
105
        ))
105
        ))
106
            ->add_joins($this->get_joins())
106
            ->add_joins($this->get_joins())
107
            ->set_type(column::TYPE_TEXT)
107
            ->set_type(column::TYPE_TEXT)
108
            ->add_field("$tablealias.classname")
108
            ->add_field("{$tablealias}.classname")
109
            ->set_is_sortable(true)
109
            ->set_is_sortable(true)
110
            ->add_callback(static function(string $classname): string {
110
            ->add_callback(static function(string $classname): string {
111
                $output = '';
111
                $output = '';
112
                if (class_exists($classname)) {
112
                if (class_exists($classname)) {
113
                    $task = new $classname;
113
                    $task = new $classname;
Línea 181... Línea 181...
181
        ))
181
        ))
182
            ->add_joins($this->get_joins())
182
            ->add_joins($this->get_joins())
183
            ->set_type(column::TYPE_FLOAT)
183
            ->set_type(column::TYPE_FLOAT)
184
            ->add_field("{$tablealias}.timeend - {$tablealias}.timestart", 'duration')
184
            ->add_field("{$tablealias}.timeend - {$tablealias}.timestart", 'duration')
185
            ->set_is_sortable(true)
185
            ->set_is_sortable(true)
186
            ->add_callback(static function(float $value): string {
186
            ->add_callback([format::class, 'format_time'], 2);
187
                $duration = round($value, 2);
-
 
188
                if (empty($duration)) {
-
 
189
                    // The format_time function returns 'now' when the difference is exactly 0.
-
 
190
                    // Note: format_time performs concatenation in exactly this fashion so we should do this for consistency.
-
 
191
                    return '0 ' . get_string('secs', 'moodle');
-
 
192
                }
-
 
193
                return format_time($duration);
-
 
194
            });
-
 
Línea 195... Línea 187...
195
 
187
 
196
        // Hostname column.
188
        // Hostname column.
197
        $columns[] = (new column(
189
        $columns[] = (new column(
198
            'hostname',
190
            'hostname',
Línea 209... Línea 201...
209
            'pid',
201
            'pid',
210
            new lang_string('pid', 'admin'),
202
            new lang_string('pid', 'admin'),
211
            $this->get_entity_name()
203
            $this->get_entity_name()
212
        ))
204
        ))
213
            ->add_joins($this->get_joins())
205
            ->add_joins($this->get_joins())
214
            ->set_type(column::TYPE_INTEGER)
-
 
215
            ->add_field("{$tablealias}.pid")
206
            ->add_field("{$tablealias}.pid")
216
            ->set_is_sortable(true)
207
            ->set_is_sortable(true);
217
            // Although this is an integer column, it doesn't make sense to perform numeric aggregation on it.
-
 
218
            ->set_disabled_aggregation(['avg', 'count', 'countdistinct', 'max', 'min', 'sum']);
-
 
Línea 219... Línea 208...
219
 
208
 
220
        // Database column.
209
        // Database column.
221
        $columns[] = (new column(
210
        $columns[] = (new column(
222
            'database',
211
            'database',
223
            new lang_string('task_dbstats', 'admin'),
212
            new lang_string('task_dbstats', 'admin'),
224
            $this->get_entity_name()
213
            $this->get_entity_name()
225
        ))
214
        ))
226
            ->add_joins($this->get_joins())
-
 
227
            ->set_type(column::TYPE_INTEGER)
215
            ->add_joins($this->get_joins())
228
            ->add_fields("{$tablealias}.dbreads, {$tablealias}.dbwrites")
216
            ->add_fields("{$tablealias}.dbreads, {$tablealias}.dbwrites")
229
            ->set_is_sortable(true, ["{$tablealias}.dbreads", "{$tablealias}.dbwrites"])
217
            ->set_is_sortable(true, ["{$tablealias}.dbreads", "{$tablealias}.dbwrites"])
230
            ->add_callback(static function(int $value, stdClass $row): string {
218
            ->add_callback(static function($value, stdClass $row): string {
231
                $output = '';
219
                $output = '';
232
                $output .= \html_writer::div(get_string('task_stats:dbreads', 'admin', $row->dbreads));
220
                $output .= \html_writer::div(get_string('task_stats:dbreads', 'admin', $row->dbreads));
233
                $output .= \html_writer::div(get_string('task_stats:dbwrites', 'admin', $row->dbwrites));
221
                $output .= \html_writer::div(get_string('task_stats:dbwrites', 'admin', $row->dbwrites));
234
                return $output;
222
                return $output;
235
            })
-
 
236
            // Although this is an integer column, it doesn't make sense to perform numeric aggregation on it.
-
 
Línea 237... Línea 223...
237
            ->set_disabled_aggregation(['avg', 'count', 'countdistinct', 'max', 'min', 'sum']);
223
            });
238
 
224
 
239
        // Database reads column.
225
        // Database reads column.
240
        $columns[] = (new column(
226
        $columns[] = (new column(
Línea 283... Línea 269...
283
     * Return list of all available filters
269
     * Return list of all available filters
284
     *
270
     *
285
     * @return filter[]
271
     * @return filter[]
286
     */
272
     */
287
    protected function get_all_filters(): array {
273
    protected function get_all_filters(): array {
288
        global $DB;
-
 
289
 
-
 
290
        $tablealias = $this->get_table_alias('task_log');
274
        $tablealias = $this->get_table_alias('task_log');
Línea 291... Línea 275...
291
 
275
 
292
        // Name filter (Filter by classname).
276
        // Name filter (Filter by classname).
293
        $filters[] = (new filter(
277
        $filters[] = (new filter(
Línea 342... Línea 326...
342
        $filters[] = (new filter(
326
        $filters[] = (new filter(
343
            text::class,
327
            text::class,
344
            'output',
328
            'output',
345
            new lang_string('task_logoutput', 'admin'),
329
            new lang_string('task_logoutput', 'admin'),
346
            $this->get_entity_name(),
330
            $this->get_entity_name(),
347
            $DB->sql_cast_to_char("{$tablealias}.output")
331
            "{$tablealias}.output"
348
        ))
332
        ))
349
            ->add_joins($this->get_joins());
333
            ->add_joins($this->get_joins());
Línea 350... Línea 334...
350
 
334
 
351
        // Start time filter.
335
        // Start time filter.