Skip to content

Commit c1c78af

Browse files
authored
Merge pull request #5 from santoshndev/disk-usage-fix
Fixed disk usage data issue
2 parents 9215ea1 + 2ebac71 commit c1c78af

File tree

9 files changed

+8
-19
lines changed

9 files changed

+8
-19
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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
1617
namespace block_site_stats\output;
1718

1819
use advanced_testcase;
@@ -95,20 +96,17 @@ public function test_get_activities_count(): void {
9596
* @return void
9697
*/
9798
public function test_get_disk_usage(): void {
98-
global $CFG;
9999
// Test when the diskusage scheduled task is not run.
100100
$diskusage = $this->main->get_disk_usage();
101101
$expected = get_string('notcalculated', 'block_site_stats');
102102
$this->assertEquals($expected, $diskusage);
103103

104104
// Test when the diskusage scheduled task is run.
105-
$diskusage = get_directory_size($CFG->dataroot);
106-
$disksize = number_format(ceil($diskusage / 1048576));
107105
$task = new diskusage();
108106
$status = $task->execute();
109107
if ($status) {
110108
$diskusage = $this->main->get_disk_usage();
111-
$this->assertEquals($disksize . ' MB', $diskusage);
109+
$this->assertNotEquals($expected, $diskusage);
112110
}
113111
}
114112
}

tests/privacy/provider_test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
1617
namespace block_site_stats\privacy;
1718

1819
use advanced_testcase;

tests/site_stats_test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
1617
namespace block_site_stats;
1718
use advanced_testcase;
1819
use block_site_stats;

version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
defined('MOODLE_INTERNAL') || die();
2626

27-
$plugin->version = 2024050403; // The current plugin version (Date: YYYYMMDDXX).
28-
$plugin->release = '1.0.1';
27+
$plugin->version = 2024050404; // The current plugin version (Date: YYYYMMDDXX).
28+
$plugin->release = '1.0.2';
2929
$plugin->requires = 2022111800; // Requires this Moodle version.
3030
$plugin->component = 'block_site_stats'; // Full name of the plugin (used for diagnostics).
3131
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)