Überarbeitung Property
This commit is contained in:
		
							parent
							
								
									67c0d85213
								
							
						
					
					
						commit
						992e299829
					
				@ -139,7 +139,7 @@ body.overview main{
 | 
				
			|||||||
      "chart3 chart3 chart3 chart2 chart2 chart2 chart4 chart4"
 | 
					      "chart3 chart3 chart3 chart2 chart2 chart2 chart4 chart4"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
body.property main{
 | 
					body.timeline main{
 | 
				
			||||||
  grid-template-columns: repeat(4, minmax(10%, 50%));
 | 
					  grid-template-columns: repeat(4, minmax(10%, 50%));
 | 
				
			||||||
    grid-template-rows: repeat(3, 1fr) 4em;
 | 
					    grid-template-rows: repeat(3, 1fr) 4em;
 | 
				
			||||||
    grid-template-areas:
 | 
					    grid-template-areas:
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
@extends('base')
 | 
					@extends('base')
 | 
				
			||||||
@section('body-class', 'property')
 | 
					@section('body-class', 'timeline')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@section('header')
 | 
					@section('header')
 | 
				
			||||||
<span>Property {{ $base['property_platform_id'] }}</span><button popovertarget="prop-details"></button>
 | 
					<span>Property {{ $base['property_platform_id'] }}</span><button popovertarget="prop-details"></button>
 | 
				
			||||||
@ -28,7 +28,7 @@
 | 
				
			|||||||
<article class="header" style="grid-area: chart1;">
 | 
					<article class="header" style="grid-area: chart1;">
 | 
				
			||||||
    <header>
 | 
					    <header>
 | 
				
			||||||
        <h2 id="belegung-title">
 | 
					        <h2 id="belegung-title">
 | 
				
			||||||
            Belegung am {{ json_decode($extractiondates)[0] }}
 | 
					            Belegung am
 | 
				
			||||||
        </h2>
 | 
					        </h2>
 | 
				
			||||||
    </header>
 | 
					    </header>
 | 
				
			||||||
    <div id="chart-calendar"></div>
 | 
					    <div id="chart-calendar"></div>
 | 
				
			||||||
@ -169,9 +169,12 @@ const chartCapacity = document.getElementById('chart-capacity');
 | 
				
			|||||||
const cCapacity = echarts.init(chartCapacity);
 | 
					const cCapacity = echarts.init(chartCapacity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const cCapacityOptions = {
 | 
					const cCapacityOptions = {
 | 
				
			||||||
 | 
					    legend: {
 | 
				
			||||||
 | 
					        data: ['Auslastung Property', 'Auslastung {{ $base['region_name'] }}', 'Auslastung alle Regionen']
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
  tooltip: {
 | 
					  tooltip: {
 | 
				
			||||||
    trigger: 'axis',
 | 
					    trigger: 'axis',
 | 
				
			||||||
    formatter: 'Datum Scraping: {b}<br />Verfügbarkeit: {c} %'
 | 
					    valueFormatter: (value) => value.toFixed(2)+' %'
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  grid: {
 | 
					  grid: {
 | 
				
			||||||
    top: 20,
 | 
					    top: 20,
 | 
				
			||||||
@ -183,7 +186,7 @@ const cCapacityOptions = {
 | 
				
			|||||||
  xAxis: {
 | 
					  xAxis: {
 | 
				
			||||||
    type: 'category',
 | 
					    type: 'category',
 | 
				
			||||||
    boundaryGap: false,
 | 
					    boundaryGap: false,
 | 
				
			||||||
    data: {!! json_encode($capacities['dates']) !!},
 | 
					    data: {!! json_encode($propertyCapacities['dates']) !!},
 | 
				
			||||||
    name: 'Zeitpunkt Scraping',
 | 
					    name: 'Zeitpunkt Scraping',
 | 
				
			||||||
    nameLocation: 'center',
 | 
					    nameLocation: 'center',
 | 
				
			||||||
    nameGap: 24,
 | 
					    nameGap: 24,
 | 
				
			||||||
@ -202,18 +205,26 @@ const cCapacityOptions = {
 | 
				
			|||||||
      fontWeight: 'bold',
 | 
					      fontWeight: 'bold',
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  series: [{
 | 
					  series: [
 | 
				
			||||||
      name: 'Auslastung',
 | 
					 | 
				
			||||||
      type: 'line',
 | 
					 | 
				
			||||||
      symbolSize: 7,
 | 
					 | 
				
			||||||
      data: {!! json_encode($capacities['capacities']) !!}
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        name: 'Auslastung Region',
 | 
					          name: 'Auslastung Property',
 | 
				
			||||||
        type: 'line',
 | 
					          type: 'line',
 | 
				
			||||||
        symbolSize: 7,
 | 
					          symbolSize: 7,
 | 
				
			||||||
        data: {!! json_encode($capacities['capacities']) !!}
 | 
					          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);
 | 
					cCapacity.setOption(cCapacityOptions);
 | 
				
			||||||
@ -225,7 +236,7 @@ const h2Belegung = document.getElementById('belegung-title');
 | 
				
			|||||||
const cCalendarOptions = {
 | 
					const cCalendarOptions = {
 | 
				
			||||||
    timeline: {
 | 
					    timeline: {
 | 
				
			||||||
        show: false,
 | 
					        show: false,
 | 
				
			||||||
        data: {!! $extractiondates !!},
 | 
					        data: {!! json_encode($propertyCapacities['dates']) !!},
 | 
				
			||||||
        axisType: 'time',
 | 
					        axisType: 'time',
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    visualMap: {
 | 
					    visualMap: {
 | 
				
			||||||
 | 
				
			|||||||
@ -24,31 +24,44 @@ Route::get('/', function () {
 | 
				
			|||||||
Route::get('/prop/{id}', function (int $id) {
 | 
					Route::get('/prop/{id}', function (int $id) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $propertyBase = Api::propertyBase($id);
 | 
					    $propertyBase = Api::propertyBase($id);
 | 
				
			||||||
    $extractions = Api::propertyExtractions($id);
 | 
					    $calendars = Api::propertyExtractions($id);
 | 
				
			||||||
    $propertyCapacities = Api::propertyCapacities($id);
 | 
					    $propertyCapacities = Api::propertyCapacities($id);
 | 
				
			||||||
    $propertyNeighbours = Api::propertyNeighbours($id);
 | 
					    $propertyNeighbours = Api::propertyNeighbours($id);
 | 
				
			||||||
    //$regionCapacities = Api::regionCapacities(-1);
 | 
					    $regionCapacitiesRegion = Api::regionCapacities($propertyBase[0]['region_id']);
 | 
				
			||||||
    $regionCapacities = [];
 | 
					    $regionCapacitiesAll = Api::regionCapacities(-1);
 | 
				
			||||||
 | 
					    $regionCapacities = [[],[]];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $propertyCapacitiesMonthly = [];
 | 
					    $propertyCapacitiesMonthly = [];
 | 
				
			||||||
    $propertyCapacitiesDaily = [];
 | 
					    $propertyCapacitiesDaily = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    foreach ($extractions as $extraction) {
 | 
					    foreach ($propertyCapacities['dates'] as $date) {
 | 
				
			||||||
        $propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $extraction['created_at']);
 | 
					        $propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $date);
 | 
				
			||||||
        $propertyCapacitiesDaily[] = Api::propertyCapacitiesDaily($id, $extraction['created_at']);
 | 
					        $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 = [];
 | 
					    $data = [];
 | 
				
			||||||
    $dates = [];
 | 
					    $dates = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    foreach ($extractions as $ext) {
 | 
					    foreach ($calendars as $el) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $series = [];
 | 
					        $series = [];
 | 
				
			||||||
        $dates[] = $ext['created_at'];
 | 
					        $calendar = json_decode($el['calendar'], 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $extCalendar = json_decode($ext['calendar'], 1);
 | 
					        foreach ($calendar as $date => $status) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        foreach ($extCalendar as $date => $status) {
 | 
					 | 
				
			||||||
            $series[] = [$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) {
 | 
					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', ['regionCapacities' => $regionCapacities]);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    return view('region', ['capacities' => $regionCapacities]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
@ -400,6 +400,7 @@ class Database:
 | 
				
			|||||||
				p.property_platform_id,
 | 
									p.property_platform_id,
 | 
				
			||||||
				p.created_at as first_found,
 | 
									p.created_at as first_found,
 | 
				
			||||||
				p.last_found,
 | 
									p.last_found,
 | 
				
			||||||
 | 
									r.id as region_id,
 | 
				
			||||||
				r.name as region_name 
 | 
									r.name as region_name 
 | 
				
			||||||
			FROM
 | 
								FROM
 | 
				
			||||||
				consultancy_d.properties p
 | 
									consultancy_d.properties p
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ def property_capacities(id: int):
 | 
				
			|||||||
		count_days.append(len(liste))
 | 
							count_days.append(len(liste))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	counts = pl.DataFrame({"count_days" : count_days, "sum" : sum_hor})
 | 
						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):
 | 
						for row in counts.rows(named=True):
 | 
				
			||||||
		max_capacity = row['count_days'] * 2
 | 
							max_capacity = row['count_days'] * 2
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user