Skip to content

Commit 5c8df75

Browse files
committed
Fixed disk usage data issue
1 parent 9215ea1 commit 5c8df75

File tree

7 files changed

+34
-48
lines changed

7 files changed

+34
-48
lines changed

classes/output/main.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,7 @@ public function get_disk_usage() {
9494
return get_string('notcalculated', 'block_site_stats');
9595
}
9696

97-
$unit = get_string('sizemb', 'block_site_stats');
98-
if ($diskusagecache > 1024) {
99-
$unit = get_string('sizegb', 'block_site_stats');
100-
}
101-
102-
return $diskusagecache . $unit;
97+
return $diskusagecache;
10398
}
10499
/**
105100
* Export the data for template

classes/task/diskusage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function execute() {
4444
global $CFG;
4545
$cache = cache::make('block_site_stats', 'sitestats');
4646
$diskusage = get_directory_size($CFG->dataroot);
47-
$disksize = number_format(ceil($diskusage / 1048576));
47+
$disksize = display_size($diskusage);
4848
$cache->set('diskusage', $disksize);
4949
return true;
5050
}

lang/en/block_site_stats.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@
3131
$string['privacy:metadata'] = 'The Site Statistics block only shows data stored in other locations.';
3232
$string['site_stats:myaddinstance'] = 'Add a new Site Statistics block to Dashboard';
3333
$string['site_stats:view'] = 'View Site Statistics block content';
34-
$string['sizegb'] = ' GB';
35-
$string['sizemb'] = ' MB';
3634
$string['users'] = 'Users';

lang/hi/block_site_stats.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@
3131
$string['privacy:metadata'] = 'साइट आँकड़े ब्लॉक केवल अन्य स्थानों में संग्रहित डेटा दिखाता है।';
3232
$string['site_stats:myaddinstance'] = 'डैशबोर्ड पर नया साइट आँकड़ा ब्लॉक जोड़ें';
3333
$string['site_stats:view'] = 'साइट आँकड़े ब्लॉक की सामग्री देखें';
34-
$string['sizegb'] = ' जीबी';
35-
$string['sizemb'] = ' एमबी';
3634
$string['users'] = 'उपयोगकर्ता';

lang/mr/block_site_stats.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@
3131
$string['privacy:metadata'] = 'साइट सांख्यिकी ब्लॉक फक्त इतर स्थानांतील डेटा दर्शवितो.';
3232
$string['site_stats:myaddinstance'] = 'डॅशबोर्डवर नविन साइट सांख्यिकी ब्लॉक जोडा';
3333
$string['site_stats:view'] = 'साइट सांख्यिकी ब्लॉक सामग्री पहा';
34-
$string['sizegb'] = ' जीबी';
35-
$string['sizemb'] = ' एमबी';
3634
$string['users'] = 'वापरकर्ते';

tests/output/main_test.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,17 @@ public function test_get_activities_count(): void {
9595
* @return void
9696
*/
9797
public function test_get_disk_usage(): void {
98-
global $CFG;
9998
// Test when the diskusage scheduled task is not run.
10099
$diskusage = $this->main->get_disk_usage();
101100
$expected = get_string('notcalculated', 'block_site_stats');
102101
$this->assertEquals($expected, $diskusage);
103102

104103
// Test when the diskusage scheduled task is run.
105-
$diskusage = get_directory_size($CFG->dataroot);
106-
$disksize = number_format(ceil($diskusage / 1048576));
107104
$task = new diskusage();
108105
$status = $task->execute();
109106
if ($status) {
110107
$diskusage = $this->main->get_disk_usage();
111-
$this->assertEquals($disksize . ' MB', $diskusage);
108+
$this->assertNotEquals($expected, $diskusage);
112109
}
113110
}
114111
}

version.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
<?php
2-
// This file is part of Moodle - http://moodle.org/
3-
//
4-
// Moodle is free software: you can redistribute it and/or modify
5-
// it under the terms of the GNU General Public License as published by
6-
// the Free Software Foundation, either version 3 of the License, or
7-
// (at your option) any later version.
8-
//
9-
// Moodle is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU General Public License for more details.
13-
//
14-
// You should have received a copy of the GNU General Public License
15-
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16-
17-
/**
18-
* Version details
19-
*
20-
* @package block_site_stats
21-
* @copyright 2024 Santosh Nagargoje <santosh.nag2217@gmail.com>
22-
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23-
*/
24-
25-
defined('MOODLE_INTERNAL') || die();
26-
27-
$plugin->version = 2024050403; // The current plugin version (Date: YYYYMMDDXX).
28-
$plugin->release = '1.0.1';
29-
$plugin->requires = 2022111800; // Requires this Moodle version.
30-
$plugin->component = 'block_site_stats'; // Full name of the plugin (used for diagnostics).
31-
$plugin->maturity = MATURITY_STABLE;
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Version details
19+
*
20+
* @package block_site_stats
21+
* @copyright 2024 Santosh Nagargoje <santosh.nag2217@gmail.com>
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
defined('MOODLE_INTERNAL') || die();
26+
27+
$plugin->version = 2024050404; // The current plugin version (Date: YYYYMMDDXX).
28+
$plugin->release = '1.0.2';
29+
$plugin->requires = 2022111800; // Requires this Moodle version.
30+
$plugin->component = 'block_site_stats'; // Full name of the plugin (used for diagnostics).
31+
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)