Skip to content

Commit de14625

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

File tree

6 files changed

+3
-17
lines changed

6 files changed

+3
-17
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
}

0 commit comments

Comments
 (0)