Überarbeitung Property

main
Giò Diani 2025-01-12 16:49:29 +01:00
parent 67c0d85213
commit 992e299829
5 changed files with 69 additions and 34 deletions

View File

@ -139,7 +139,7 @@ body.overview main{
"chart3 chart3 chart3 chart2 chart2 chart2 chart4 chart4"
}
body.property main{
body.timeline main{
grid-template-columns: repeat(4, minmax(10%, 50%));
grid-template-rows: repeat(3, 1fr) 4em;
grid-template-areas:

View File

@ -1,5 +1,5 @@
@extends('base')
@section('body-class', 'property')
@section('body-class', 'timeline')
@section('header')
<span>Property {{ $base['property_platform_id'] }}</span><button popovertarget="prop-details"></button>
@ -28,7 +28,7 @@
<article class="header" style="grid-area: chart1;">
<header>
<h2 id="belegung-title">
Belegung am {{ json_decode($extractiondates)[0] }}
Belegung am
</h2>
</header>
<div id="chart-calendar"></div>
@ -169,9 +169,12 @@ const chartCapacity = document.getElementById('chart-capacity');
const cCapacity = echarts.init(chartCapacity);
const cCapacityOptions = {
legend: {
data: ['Auslastung Property', 'Auslastung {{ $base['region_name'] }}', 'Auslastung alle Regionen']
},
tooltip: {
trigger: 'axis',
formatter: 'Datum Scraping: {b}<br />Verfügbarkeit: {c} %'
valueFormatter: (value) => value.toFixed(2)+'%'
},
grid: {
top: 20,
@ -183,7 +186,7 @@ const cCapacityOptions = {
xAxis: {
type: 'category',
boundaryGap: false,
data: {!! json_encode($capacities['dates']) !!},
data: {!! json_encode($propertyCapacities['dates']) !!},
name: 'Zeitpunkt Scraping',
nameLocation: 'center',
nameGap: 24,
@ -202,18 +205,26 @@ const cCapacityOptions = {
fontWeight: 'bold',
}
},
series: [{
name: 'Auslastung',
type: 'line',
symbolSize: 7,
data: {!! json_encode($capacities['capacities']) !!}
},
series: [
{
name: 'Auslastung Region',
type: 'line',
symbolSize: 7,
data: {!! json_encode($capacities['capacities']) !!}
}]
name: 'Auslastung Property',
type: 'line',
symbolSize: 7,
data: {!! json_encode($propertyCapacities['capacities']) !!}
},
{
name: 'Auslastung {{ $base['region_name'] }}',
type: 'line',
symbolSize: 7,
data: {!! json_encode($regionCapacities[0]) !!}
},
{
name: 'Auslastung alle Regionen',
type: 'line',
symbolSize: 7,
data: {!! json_encode($regionCapacities[1]) !!}
}
]
};
cCapacity.setOption(cCapacityOptions);
@ -225,7 +236,7 @@ const h2Belegung = document.getElementById('belegung-title');
const cCalendarOptions = {
timeline: {
show: false,
data: {!! $extractiondates !!},
data: {!! json_encode($propertyCapacities['dates']) !!},
axisType: 'time',
},
visualMap: {

View File

@ -24,31 +24,44 @@ Route::get('/', function () {
Route::get('/prop/{id}', function (int $id) {
$propertyBase = Api::propertyBase($id);
$extractions = Api::propertyExtractions($id);
$calendars = Api::propertyExtractions($id);
$propertyCapacities = Api::propertyCapacities($id);
$propertyNeighbours = Api::propertyNeighbours($id);
//$regionCapacities = Api::regionCapacities(-1);
$regionCapacities = [];
$regionCapacitiesRegion = Api::regionCapacities($propertyBase[0]['region_id']);
$regionCapacitiesAll = Api::regionCapacities(-1);
$regionCapacities = [[],[]];
$propertyCapacitiesMonthly = [];
$propertyCapacitiesDaily = [];
foreach ($extractions as $extraction) {
$propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $extraction['created_at']);
$propertyCapacitiesDaily[] = Api::propertyCapacitiesDaily($id, $extraction['created_at']);
foreach ($propertyCapacities['dates'] as $date) {
$propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $date);
$propertyCapacitiesDaily[] = Api::propertyCapacitiesDaily($id, $date);
}
// filter out all date, which were not scraped for the property
foreach ($regionCapacitiesAll['dates'] as $index => $date) {
if(in_array($date, $propertyCapacities['dates'])){
$regionCapacities[0][] = $regionCapacitiesAll['capacities'][$index];
}
}
foreach ($regionCapacitiesRegion['dates'] as $index => $date) {
if(in_array($date, $propertyCapacities['dates'])){
$regionCapacities[1][] = $regionCapacitiesRegion['capacities'][$index];
}
}
// prepare data for calendar chart
$data = [];
$dates = [];
foreach ($extractions as $ext) {
foreach ($calendars as $el) {
$series = [];
$dates[] = $ext['created_at'];
$calendar = json_decode($el['calendar'], 1);
$extCalendar = json_decode($ext['calendar'], 1);
foreach ($extCalendar as $date => $status) {
foreach ($calendar as $date => $status) {
$series[] = [$date, $status];
}
@ -56,17 +69,27 @@ Route::get('/prop/{id}', function (int $id) {
}
return view('property', ['base' => $propertyBase[0], "extractiondates" => json_encode($dates), "calendar" => $data, 'capacities' => $propertyCapacities, 'capacitiesMonthly' => $propertyCapacitiesMonthly, 'capacitiesDaily' => $propertyCapacitiesDaily, 'regionCapacities' => $regionCapacities, 'neighbours' => $propertyNeighbours]);
return view('property', [
'base' => $propertyBase[0],
'extractiondates' => json_encode($propertyCapacities['dates']),
'calendar' => $data,
'propertyCapacities' => $propertyCapacities,
'capacitiesMonthly' => $propertyCapacitiesMonthly,
'capacitiesDaily' => $propertyCapacitiesDaily,
'regionCapacities' => $regionCapacities,
'neighbours' => $propertyNeighbours
]);
});
Route::get('/region/{id}', function (int $id) {
$regionCapacities = Api::regionCapacities($id);
$regionCapacitiesRegion = Api::regionCapacities($id);
$regionCapacitiesAll = Api::regionCapacities(-1);
$regionCapacities = [$regionCapacitiesAll, $regionCapacitiesRegion];
dump($regionCapacities);
return view('region', ['capacities' => $regionCapacities]);
return view('region', ['regionCapacities' => $regionCapacities]);
});

View File

@ -400,6 +400,7 @@ class Database:
p.property_platform_id,
p.created_at as first_found,
p.last_found,
r.id as region_id,
r.name as region_name
FROM
consultancy_d.properties p

View File

@ -28,7 +28,7 @@ def property_capacities(id: int):
count_days.append(len(liste))
counts = pl.DataFrame({"count_days" : count_days, "sum" : sum_hor})
result = {"capacities": [], "dates": extractions['created_at'].cast(pl.Datetime).to_list() }
result = {"capacities": [], "dates": extractions['created_at'].cast(pl.Date).to_list() }
for row in counts.rows(named=True):
max_capacity = row['count_days'] * 2