Skip to content

Commit

Permalink
Remove dead code.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed May 20, 2022
1 parent 9d83051 commit fe220b6
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 248 deletions.
48 changes: 0 additions & 48 deletions app/Helpers/CachingRssRetriever.php

This file was deleted.

39 changes: 0 additions & 39 deletions app/Helpers/CachingWikiPageRetriever.php

This file was deleted.

93 changes: 0 additions & 93 deletions app/Helpers/LcaStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,97 +56,4 @@ public static function getWasteStats($group = null)

return DB::select(DB::raw($sql));
}

/**
* DEPRECATED IN PRODUCTION
*
* TO BE MOVED SOMEWHERE ELSE
*
* CAN BE USED FOR CHECKING CURRENT STATUS OF STATIC RATIOS
*
* Calculates the average footprint per kilo of fixed devices.
*
* Calculated by looking at all of the fixed devices in the database,
* and dividing the total footprint of their categories by the total weight of their
* categories.
*
* Misc categories should not be included therefore
* weight and footprint = must have 0 values.
*
* This ratio of CO2 to kilo of device is then used to estimate the footprint of
* Misc devices that are recorded in the DB.
*/
public static function calculatetEmissionRatioPowered()
{
$value = DB::select(DB::raw('
SELECT
SUM(c.footprint) / SUM(c.weight) AS ratio
FROM devices d
JOIN categories c ON c.idcategories = d.category
WHERE c.powered = 1
AND d.repair_status = 1
AND d.category <> 46
'));

return $value[0]->ratio;
}

public static function calculatetEmissionRatioUnpowered()
{
$value = DB::select(DB::raw('
SELECT
SUM(c.footprint) / SUM(IF(d.estimate = 0, c.weight, d.estimate)) AS ratio
FROM devices d
JOIN categories c ON c.idcategories = d.category
WHERE c.powered = 0
AND d.repair_status = 1
AND d.category <> 50
'));

return $value[0]->ratio;
}

/**
* BORKED ATTEMPT TO APPLY REQUEST FILTERS TO STATS QUERY.
*
* See \app\Http\Controllers\ApiController::getDevices() for more info.
*
* @ToDo Determine if this is useful and fix.
*
* It could replace getWasteStats() if it worked.
*/
public static function getWasteStatsFiltered($filters = [])
{
for ($i = count($filters) - 1; $i >= 0; $i--) {
if (strstr($filters[$i][0], 'repair_status')) {
unset($filters[$i]);
}
}
$filters[] = ['devices.repair_status', '=', 1];
$dF = self::getDisplacementFactor();
$eR = self::getEmissionRatioPowered();
$uR = self::getEmissionRatioUnpowered();

$t1 = DB::table('devices')->select(
DB::raw("
CASE WHEN (categories.powered = 1) THEN (CASE WHEN (categories.weight = 0) THEN devices.estimate ELSE categories.weight END) ELSE 0 END AS powered_device_weights,
CASE WHEN (categories.powered = 0) THEN (CASE WHEN (devices.estimate = 0) THEN categories.weight ELSE devices.estimate END) ELSE 0 END AS unpowered_device_weights,
CASE WHEN (categories.powered = 1) THEN (CASE WHEN (categories.weight = 0) THEN (devices.estimate * $eR) ELSE categories.footprint END) ELSE 0 END AS powered_footprints,
CASE WHEN (categories.powered = 0) THEN (CASE WHEN (devices.estimate = 0) THEN categories.footprint ELSE (devices.estimate * $uR) END) ELSE 0 END AS unpowered_footprints
")
)
->join('categories', 'devices.category', '=', 'categories.idcategories')
->join('events', 'events.idevents', '=', 'devices.event')
->join('groups', 'events.group', '=', 'groups.idgroups')
->where($filters)
->get();

$t2 = DB::table($t1)->select(DB::raw("
SUM(powered_device_weights) AS powered_waste,
SUM(unpowered_device_weights) AS unpowered_waste,
SUM(powered_footprints) * $dF AS powered_footprint,
SUM(unpowered_footprints) * $dF AS unpowered_footprint
"))->first();
logger(print_r($t2, 1));
}
}
8 changes: 0 additions & 8 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@

namespace App\Http\Controllers;

use App\Device;
use App\EventsUsers;
use App\Group;
use App\Helpers\CachingRssRetriever;
use App\Helpers\CachingWikiPageRetriever;
use App\Helpers\Fixometer;
use App\Party;
use App\Services\DiscourseService;
use App\User;
use App\UserGroups;
use App\UsersSkills;
use Auth;
use Cache;
use DB;
Expand Down
10 changes: 0 additions & 10 deletions app/Rss.php

This file was deleted.

1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<testsuite name="Unit">
<directory suffix=".php">./tests/Unit</directory>
<exclude>./tests/Unit/CharsetTest.php</exclude>
<exclude>./tests/Unit/WikiPageRetrieverTest.php</exclude>
</testsuite>
</testsuites>
<filter>
Expand Down
49 changes: 0 additions & 49 deletions tests/Unit/WikiPageRetrieverTest.php

This file was deleted.

0 comments on commit fe220b6

Please sign in to comment.