mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 21:13:40 +02:00
fix: remove about/battlestation
This commit is contained in:
parent
56cf142e0d
commit
1de2f897e0
10 changed files with 1 additions and 966 deletions
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\Config\ConfigModel;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/Config.php");
|
||||
|
||||
class GET_Battlestation extends Database {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(ConfigModel::REF_MB_ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(ConfigModel::FRIENDLY_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_config(): array {
|
||||
return $this->results = $this->db
|
||||
->for(ConfigModel::NAME)
|
||||
->where($this->query)
|
||||
->order([ConfigModel::DATE_BUILT->value => "DESC"])
|
||||
->select(ConfigModel::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(ConfigModel::FRIENDLY_NAME->value, $this->query);
|
||||
|
||||
$this->get_config();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\ChassisTable;
|
||||
use VLW\Database\Tables\Battlestation\Config\ChassisMbTable;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Chassis.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/ChassisMb.php");
|
||||
|
||||
class GET_BattlestationChassis extends Database {
|
||||
private const REL_MOTHERBOARDS = "motherboards";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(ChassisTable::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(ChassisTable::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(ChassisTable::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(ChassisTable::STORAGE_TWOINCHFIVE->value))
|
||||
->type(Type::NUMBER)
|
||||
->type(Type::NULL)
|
||||
->min(0)
|
||||
->max(parent::MYSQL_TINYINT_MAX_LENGTH),
|
||||
|
||||
(new Rules(ChassisTable::STORAGE_THREEINCHFIVE->value))
|
||||
->type(Type::NUMBER)
|
||||
->type(Type::NULL)
|
||||
->min(0)
|
||||
->max(parent::MYSQL_TINYINT_MAX_LENGTH),
|
||||
|
||||
(new Rules(ChassisTable::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_motherboards(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_MOTHERBOARDS] = $this->db
|
||||
->for(ChassisMbTable::NAME)
|
||||
->where([ChassisMbTable::REF_CHASSIS_ID->value => $result[ChassisTable::ID->value]])
|
||||
->select(ChassisMbTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_chassis(): array {
|
||||
return $this->results = $this->db
|
||||
->for(ChassisTable::NAME)
|
||||
->where($this->query)
|
||||
->order([ChassisTable::DATE_AQUIRED->value => "DESC"])
|
||||
->select(ChassisTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(ChassisTable::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(ChassisTable::VENDOR_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_chassis();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_motherboards();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\{
|
||||
CoolerModel
|
||||
};
|
||||
use VLW\Database\Tables\Battlestation\Config\MbCpuCoolerModel;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Coolers.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbCpuCooler.php");
|
||||
|
||||
class GET_BattlestationCoolers extends Database {
|
||||
private const REL_MOTHERBOARDS = "motherboards";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(CoolerModel::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(CoolerModel::TYPE_LIQUID->value))
|
||||
->type(Type::BOOLEAN),
|
||||
|
||||
(new Rules(CoolerModel::SIZE_FAN->value))
|
||||
->type(Type::NULL)
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_INTR_MAX_LENGTH),
|
||||
|
||||
(new Rules(CoolerModel::SIZE_RADIATOR->value))
|
||||
->type(Type::NULL)
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_INTR_MAX_LENGTH),
|
||||
|
||||
(new Rules(CoolerModel::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(CoolerModel::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(CoolerModel::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_motherboards(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_MOTHERBOARDS] = $this->db
|
||||
->for(MbCoolerModel::NAME)
|
||||
->where([MbCoolerModel::REF_COOLER_ID->value => $result[CoolerModel::ID->value]])
|
||||
->select(MbCoolerModel::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_coolers(): array {
|
||||
return $this->results = $this->db
|
||||
->for(CoolerModel::NAME)
|
||||
->where($this->query)
|
||||
->order([CoolerModel::DATE_AQUIRED->value => "DESC"])
|
||||
->select(CoolerModel::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(CoolerModel::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(CoolerModel::VENDOR_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_coolers();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_motherboards();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\{
|
||||
CpuTable,
|
||||
ClassEnum
|
||||
};
|
||||
use VLW\Database\Tables\Battlestation\Config\MbCpuCoolerModel;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Cpu.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbCpuCooler.php");
|
||||
|
||||
class GET_BattlestationCpu extends Database {
|
||||
private const REL_MOTHERBOARDS = "motherboards";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(CpuTable::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(CpuTable::CLOCK_BASE->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1),
|
||||
|
||||
(new Rules(CpuTable::CLOCK_TURBO->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1),
|
||||
|
||||
(new Rules(CpuTable::CORE_COUNT_PERFORMANCE->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_TINYINT_MAX_LENGTH),
|
||||
|
||||
(new Rules(CpuTable::CORE_COUNT_EFFICIENCY->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_TINYINT_MAX_LENGTH),
|
||||
|
||||
(new Rules(CpuTable::CORE_THREADS->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_TINYINT_MAX_LENGTH),
|
||||
|
||||
(new Rules(CpuTable::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(CpuTable::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(CpuTable::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_motherboards(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_MOTHERBOARDS] = $this->db
|
||||
->for(MbCpuCoolerModel::NAME)
|
||||
->where([MbCpuCoolerModel::REF_CPU_ID->value => $result[CpuTable::ID->value]])
|
||||
->select(MbCpuCoolerModel::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_cpu(): array {
|
||||
return $this->results = $this->db
|
||||
->for(CpuTable::NAME)
|
||||
->where($this->query)
|
||||
->order([CpuTable::DATE_AQUIRED->value => "DESC"])
|
||||
->select(CpuTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(CpuTable::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(CpuTable::VENDOR_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_cpu();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_motherboards();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\{
|
||||
DramTable,
|
||||
DramFormfactorEnum,
|
||||
DramTechnologyEnum
|
||||
};
|
||||
use VLW\Database\Tables\Battlestation\Config\MbDramTable;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Dram.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbDram.php");
|
||||
|
||||
class GET_BattlestationDram extends Database {
|
||||
private const REL_MOTHERBOARDS = "motherboards";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(DramTable::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(DramTable::CAPACITY->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1),
|
||||
|
||||
(new Rules(DramTable::SPEED->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1),
|
||||
|
||||
(new Rules(DramTable::FORMFACTOR->value))
|
||||
->type(Type::ENUM, DramFormfactorEnum::names()),
|
||||
|
||||
(new Rules(DramTable::TECHNOLOGY->value))
|
||||
->type(Type::ENUM, DramTechnologyEnum::names()),
|
||||
|
||||
(new Rules(DramTable::ECC->value))
|
||||
->type(Type::BOOLEAN),
|
||||
|
||||
(new Rules(DramTable::BUFFERED->value))
|
||||
->type(Type::BOOLEAN),
|
||||
|
||||
(new Rules(DramTable::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(DramTable::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(DramTable::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_motherboards(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_MOTHERBOARDS] = $this->db
|
||||
->for(MbDramTable::NAME)
|
||||
->where([MbDramTable::REF_DRAM_ID->value => $result[DramTable::ID->value]])
|
||||
->select(MbDramTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_dram(): array {
|
||||
return $this->results = $this->db
|
||||
->for(DramTable::NAME)
|
||||
->where($this->query)
|
||||
->order([DramTable::DATE_AQUIRED->value => "DESC"])
|
||||
->select(DramTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(DramTable::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(DramTable::VENDOR_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_dram();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_motherboards();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\GpuTable;
|
||||
use VLW\Database\Tables\Battlestation\Config\MbGpuTable;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Gpu.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbGpu.php");
|
||||
|
||||
class GET_BattlestationGpu extends Database {
|
||||
private const REL_MOTHERBOARDS = "motherboards";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(GpuTable::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(GpuTable::MEMORY->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1),
|
||||
|
||||
(new Rules(GpuTable::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(GpuTable::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(GpuTable::VENDOR_CHIP_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(GpuTable::VENDOR_CHIP_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(GpuTable::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_motherboards(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_MOTHERBOARDS] = $this->db
|
||||
->for(MbGpuTable::NAME)
|
||||
->where([MbGpuTable::REF_GPU_ID->value => $result[GpuTable::ID->value]])
|
||||
->select(MbGpuTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_gpu(): array {
|
||||
return $this->results = $this->db
|
||||
->for(GpuTable::NAME)
|
||||
->where($this->query)
|
||||
->order([GpuTable::DATE_AQUIRED->value => "DESC"])
|
||||
->select(GpuTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(GpuTable::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(GpuTable::VENDOR_MODEL->value, $this->query);
|
||||
parent::make_wildcard_search(GpuTable::VENDOR_CHIP_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(GpuTable::VENDOR_CHIP_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_gpu();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_motherboards();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,188 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\{
|
||||
MbTable,
|
||||
MbFormfactorEnum
|
||||
};
|
||||
use VLW\Database\Tables\Battlestation\Config\{
|
||||
MbGpuTable,
|
||||
MbPsuTable,
|
||||
MbDramTable,
|
||||
MbStorageTable,
|
||||
ChassisMbTable,
|
||||
MbCpuCoolerModel
|
||||
};
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Mb.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbPsu.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbGpu.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbDram.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbStorage.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/ChassisMb.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbCpuCooler.php");
|
||||
|
||||
class GET_BattlestationMb extends Database {
|
||||
private const REL_CPU = "cpus";
|
||||
private const REL_PSU = "psus";
|
||||
private const REL_GPU = "gpus";
|
||||
private const REL_DRAM = "dram";
|
||||
private const REL_STORAGE = "storage";
|
||||
private const REL_CHASSIS = "chassis";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(MbTable::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(MbTable::FORMFACTOR->value))
|
||||
->type(Type::ENUM, MbFormfactorEnum::names()),
|
||||
|
||||
(new Rules(MbTable::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(MbTable::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(MbTable::NETWORK_ETHERNET->value))
|
||||
->type(Type::NULL)
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(MbTable::NETWORK_WLAN->value))
|
||||
->type(Type::NULL)
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(MbTable::NETWORK_BLUETOOTH->value))
|
||||
->type(Type::NULL)
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(MbTable::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_chassis(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_CHASSIS] = $this->db
|
||||
->for(ChassisMbTable::NAME)
|
||||
->where([ChassisMbTable::REF_MB_ID->value => $result[MbTable::ID->value]])
|
||||
->select(ChassisMbTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_psu(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_PSU] = $this->db
|
||||
->for(MbPsuTable::NAME)
|
||||
->where([MbPsuTable::REF_MB_ID->value => $result[MbTable::ID->value]])
|
||||
->select(MbPsuTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_cpu(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_CPU] = $this->db
|
||||
->for(MbCpuCoolerModel::NAME)
|
||||
->where([MbCpuCoolerModel::REF_MB_ID->value => $result[MbTable::ID->value]])
|
||||
->select(MbCpuCoolerModel::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_gpu(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_GPU] = $this->db
|
||||
->for(MbGpuTable::NAME)
|
||||
->where([MbGpuTable::REF_MB_ID->value => $result[MbTable::ID->value]])
|
||||
->select(MbGpuTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_dram(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_DRAM] = $this->db
|
||||
->for(MbDramTable::NAME)
|
||||
->where([MbDramTable::REF_MB_ID->value => $result[MbTable::ID->value]])
|
||||
->select(MbDramTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_storage(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_STORAGE] = $this->db
|
||||
->for(MbStorageTable::NAME)
|
||||
->where([MbStorageTable::REF_MB_ID->value => $result[MbTable::ID->value]])
|
||||
->select(MbStorageTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
private function get_motherboards(): array {
|
||||
return $this->results = $this->db
|
||||
->for(MbTable::NAME)
|
||||
->where($this->query)
|
||||
->order([MbTable::DATE_AQUIRED->value => "DESC"])
|
||||
->select(MbTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(MbTable::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(MbTable::VENDOR_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_motherboards();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_chassis();
|
||||
$this->get_cpu();
|
||||
$this->get_psu();
|
||||
$this->get_gpu();
|
||||
$this->get_dram();
|
||||
$this->get_storage();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\{
|
||||
PsuTable,
|
||||
EightyplusRatingEnum
|
||||
};
|
||||
use VLW\Database\Tables\Battlestation\Config\MbPsuTable;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Psu.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbPsu.php");
|
||||
|
||||
class GET_BattlestationPsu extends Database {
|
||||
private const REL_MOTHERBOARDS = "motherboards";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(PsuTable::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(PsuTable::POWER->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::SIZE_UINT8),
|
||||
|
||||
(new Rules(PsuTable::EIGHTYPLUS_RATING->value))
|
||||
->type(Type::ENUM, EightyplusRatingEnum::names()),
|
||||
|
||||
(new Rules(PsuTable::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(PsuTable::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(PsuTable::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_motherboards(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_MOTHERBOARDS] = $this->db
|
||||
->for(MbPsuTable::NAME)
|
||||
->where([MbPsuTable::REF_PSU_ID->value => $result[PsuTable::ID->value]])
|
||||
->select(MbPsuTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_psu(): array {
|
||||
return $this->results = $this->db
|
||||
->for(PsuTable::NAME)
|
||||
->where($this->query)
|
||||
->order([PsuTable::DATE_AQUIRED->value => "DESC"])
|
||||
->select(PsuTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(PsuTable::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(PsuTable::VENDOR_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_psu();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_motherboards();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use ReflectRules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\Database\Database;
|
||||
use VLW\Database\Tables\Battlestation\{
|
||||
StorageTable,
|
||||
StorageDiskTypeEnum,
|
||||
StorageDiskInterfaceEnum,
|
||||
StorageDiskFormfactorEnum
|
||||
};
|
||||
use VLW\Database\Tables\Battlestation\Config\MbStorageTable;
|
||||
|
||||
require_once Path::root("src/Database/Database.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Storage.php");
|
||||
require_once Path::root("src/Database/Tables/Battlestation/Config/MbStorage.php");
|
||||
|
||||
class GET_BattlestationStorage extends Database {
|
||||
private const REL_MOTHERBOARDS = "motherboards";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
private array $query;
|
||||
private array $results = [];
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(StorageTable::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(parent::UUID_LENGTH)
|
||||
->max(parent::UUID_LENGTH),
|
||||
|
||||
(new Rules(StorageTable::DISK_TYPE->value))
|
||||
->type(Type::ENUM, StorageDiskTypeEnum::names()),
|
||||
|
||||
(new Rules(StorageTable::DISK_SIZE->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::SIZE_UINT8),
|
||||
|
||||
(new Rules(StorageTable::DISK_INTERFACE->value))
|
||||
->type(Type::ENUM, StorageDiskInterfaceEnum::names()),
|
||||
|
||||
(new Rules(StorageTable::DISK_FORMFACTOR->value))
|
||||
->type(Type::ENUM, StorageDiskFormfactorEnum::names()),
|
||||
|
||||
(new Rules(StorageTable::VENDOR_NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(StorageTable::VENDOR_MODEL->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::SIZE_VARCHAR),
|
||||
|
||||
(new Rules(StorageTable::IS_RETIRED->value))
|
||||
->type(Type::BOOLEAN)
|
||||
]);
|
||||
|
||||
parent::__construct(Databases::BATTLESTATION, $this->ruleset);
|
||||
|
||||
// Use a copy of search parameters
|
||||
$this->query = $_GET;
|
||||
}
|
||||
|
||||
private function get_motherboards(): void {
|
||||
foreach ($this->results as &$result) {
|
||||
// Get motherboard id from relationship by chassis id
|
||||
$result[self::REL_MOTHERBOARDS] = $this->db
|
||||
->for(MbStorageTable::NAME)
|
||||
->where([MbStorageTable::REF_STORAGE_ID->value => $result[StorageTable::ID->value]])
|
||||
->select(MbStorageTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_storage(): array {
|
||||
return $this->results = $this->db
|
||||
->for(StorageTable::NAME)
|
||||
->where($this->query)
|
||||
->order([StorageTable::DATE_AQUIRED->value => "DESC"])
|
||||
->select(StorageTable::values())
|
||||
->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Set properties as "searchable"
|
||||
parent::make_wildcard_search(StorageTable::VENDOR_NAME->value, $this->query);
|
||||
parent::make_wildcard_search(StorageTable::VENDOR_MODEL->value, $this->query);
|
||||
|
||||
// Get hardware
|
||||
$this->get_storage();
|
||||
|
||||
// Resolve hardware relationships
|
||||
$this->get_motherboards();
|
||||
|
||||
// Return 404 Not Found if response array is empty
|
||||
return new Response($this->results, $this->results ? 200 : 404);
|
||||
}
|
||||
}
|
|
@ -88,7 +88,7 @@
|
|||
<h2>Personal</h2>
|
||||
<p>Coffee, of course.. and..</p>
|
||||
<p>At times, I become a true, amateur, armchair detective for a <span class="interests">variety of your typical-nerdy topics that I find interesting</span>. And will spend a disproportionate to real-world-personal-use amount of time reading about that stuff too.</p>
|
||||
<p>Another silent passion of mine that comes out every few years is <a href="/about/battlestation">building computers</a> and fiddling with weird networking stuff.</p>
|
||||
<p>Another silent passion of mine that comes out every few years is building computers and fiddling with weird networking stuff.</p>
|
||||
<p>And then of course I don't mind some occational gaming, and watching movies and TV-series.</p>
|
||||
</section>
|
||||
<section class="about">
|
||||
|
|
Loading…
Add table
Reference in a new issue