add statistic service & add new stats to home page
This commit is contained in:
1 parent
90e3f936fc
commit
1b36bc66fe
7 files changed
+199
-196
No files matched your search
@@ -18,6 +18,7 @@ import { SearchPageComponent } from './features/discover/search-page/search-page
|
|||||||
|
|
||||||
import { SharedModule } from './shared/shared.module';
|
import { SharedModule } from './shared/shared.module';
|
||||||
import { ToastrModule } from 'ngx-toastr';
|
import { ToastrModule } from 'ngx-toastr';
|
||||||
|
import { MinutesFormatPipe } from './shared/pipes/minutes-format/minutes-format.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -49,7 +50,7 @@ import { ToastrModule } from 'ngx-toastr';
|
|||||||
SearchPageComponent,
|
SearchPageComponent,
|
||||||
|
|
||||||
],
|
],
|
||||||
providers: [DatePipe],
|
providers: [DatePipe, MinutesFormatPipe],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
@@ -46,9 +46,4 @@ export class EntrySeenService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getYearlyStats(year: number) {
|
|
||||||
return this.http.get<any>(
|
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/stats-year/${year}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -60,9 +60,4 @@ export class EpisodeSeenService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getYearlyStats(year: number) {
|
|
||||||
return this.http.get<any>(
|
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/stats-year/${year}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class StatisticsService {
|
||||||
|
private backend_apiUrl = environment.API_URL;
|
||||||
|
private apiAction = 'statistics';
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
fetchYearlyWatchCount(year: number) {
|
||||||
|
return this.http.get<any>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/watch-count/year/${year}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchAllTimeTotalWatchTime() {
|
||||||
|
return this.http.get<any>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/watch-time`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchYearlyTotalWatchTime(year: number) {
|
||||||
|
return this.http.get<any>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}/watch-time/year/${year}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.time-color {
|
||||||
|
color: var(--shz-blue-default);
|
||||||
|
}
|
||||||
@@ -83,184 +83,106 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-xl-5 col-xxl-4 d-flex">
|
<!-- watchtime -->
|
||||||
<div class="card rounded-4 w-100 shadow-none bg-transparent border-0">
|
<div class="col-12 col-xl-4 d-flex flex-column justify-content-between">
|
||||||
<div class="card-body p-0">
|
<!-- movies watchtime -->
|
||||||
<div class="row g-4">
|
<div class="card rounded-4">
|
||||||
<div class="col-12 col-xl-6 d-flex">
|
|
||||||
<div class="card mb-0 rounded-4 w-100">
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex align-items-start justify-content-between mb-3">
|
<div class="d-flex gap-2 mb-4">
|
||||||
<div class="">
|
<h5 class="mb-0 d-flex align-items-center gap-2 fw-bold">
|
||||||
<h4 class="mb-0">97.4K</h4>
|
Total Time Spent Watching
|
||||||
<p class="mb-0">Total Users</p>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown">
|
<div class="d-flex justify-content-between p-3">
|
||||||
<a href="javascript:;" class="dropdown-toggle-nocaret options dropdown-toggle"
|
|
||||||
data-bs-toggle="dropdown">
|
<div id="watchTimeMovies">
|
||||||
<span class="material-icons-outlined fs-5">more_vert</span>
|
<div class="d-flex gap-2 mb-4">
|
||||||
</a>
|
<div
|
||||||
<ul class="dropdown-menu">
|
class="wh-48 d-flex bg-success text-success bg-opacity-10 align-items-center justify-content-center rounded-circle"
|
||||||
<li><a class="dropdown-item" href="javascript:;">Action</a></li>
|
style="min-width: 48px;">
|
||||||
<li><a class="dropdown-item" href="javascript:;">Another action</a></li>
|
<span class="material-icons-outlined">movie</span>
|
||||||
<li><a class="dropdown-item" href="javascript:;">Something else here</a></li>
|
</div>
|
||||||
</ul>
|
<h5 class="mb-0 d-flex align-items-center gap-2">
|
||||||
|
Movies
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex align-items-start justify-content">
|
||||||
|
<div class="d-flex flex-column align-items-start gap-1">
|
||||||
|
<h5 class="mb-0 time-color">{{ watchTime.allTime.movies | number }} minutes</h5>
|
||||||
|
<p class="mb-0">and it is</p>
|
||||||
|
<h5 class="mb-0 time-color">{{ watchTime.allTime.movies | minutesFormat:'hours' | number }} hours</h5>
|
||||||
|
<p class="mb-0">which is about {{watchTime.allTime.movies | minutesFormat:'days'}} days.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="chart-container2">
|
|
||||||
<div id="chart3"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center">
|
|
||||||
<p class="mb-0"><span class="text-success me-1">12.5%</span> from last month</p>
|
<div id="watchTimeSeries">
|
||||||
|
<div class="d-flex gap-2 mb-4">
|
||||||
|
<div
|
||||||
|
class="wh-48 d-flex bg-danger text-danger bg-opacity-10 align-items-center justify-content-center rounded-circle"
|
||||||
|
style="min-width: 48px;">
|
||||||
|
<span class="material-icons-outlined">tv</span>
|
||||||
|
</div>
|
||||||
|
<h5 class="mb-0 d-flex align-items-center gap-2">
|
||||||
|
Tv-Series
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex align-items-start justify-content">
|
||||||
|
<div class="d-flex flex-column align-items-start gap-1">
|
||||||
|
<h5 class="mb-0 time-color">{{ watchTime.allTime.series | number }} minutes</h5>
|
||||||
|
<p class="mb-0">and it is</p>
|
||||||
|
<h5 class="mb-0 time-color">{{ watchTime.allTime.series | minutesFormat:'hours' | number }} hours</h5>
|
||||||
|
<p class="mb-0">which is about {{watchTime.allTime.series | minutesFormat:'days'}} days.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-xl-6 d-flex">
|
|
||||||
<div class="card mb-0 rounded-4 w-100">
|
<div class="card-body align-content-center">
|
||||||
<div class="card-body">
|
|
||||||
<div class="d-flex align-items-start justify-content-between mb-1">
|
<p class="mb-0">You've spent {{ watchTime.allTime.total | minutesFormat:'days' | number }} days of your life
|
||||||
<div class="">
|
watching this crap.
|
||||||
<h4 class="mb-0">42.5K</h4>
|
<br>
|
||||||
<p class="mb-0">Active Users</p>
|
<span>{{ (watchTime.allTime.total * 100) / minutesAge | floatFormat:2 }}% of your life.</span>
|
||||||
</div>
|
|
||||||
<div class="dropdown">
|
|
||||||
<a href="javascript:;" class="dropdown-toggle-nocaret options dropdown-toggle"
|
|
||||||
data-bs-toggle="dropdown">
|
|
||||||
<span class="material-icons-outlined fs-5">more_vert</span>
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="javascript:;">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="javascript:;">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="javascript:;">Something else here</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="chart-container2">
|
|
||||||
<div id="chart2" style="min-height: 131.818px;">
|
|
||||||
<div id="apexcharts3qnjc9lg" class="apexcharts-canvas apexcharts3qnjc9lg apexcharts-theme-light"
|
|
||||||
style="width: 131px; height: 131.818px;"><svg id="SvgjsSvg1785" width="131"
|
|
||||||
height="131.81753540039062" xmlns="http://www.w3.org/2000/svg" version="1.1"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev" class="apexcharts-svg"
|
|
||||||
xmlns:data="ApexChartsNS" transform="translate(0, 0)" style="background: transparent;">
|
|
||||||
<foreignObject x="0" y="0" width="131" height="131.81753540039062">
|
|
||||||
<div class="apexcharts-legend" xmlns="http://www.w3.org/1999/xhtml"></div>
|
|
||||||
</foreignObject>
|
|
||||||
<g id="SvgjsG1787" class="apexcharts-inner apexcharts-graphical"
|
|
||||||
transform="translate(-11.5, 0)">
|
|
||||||
<defs id="SvgjsDefs1786">
|
|
||||||
<clipPath id="gridRectMask3qnjc9lg">
|
|
||||||
<rect id="SvgjsRect1788" width="162" height="180" x="-3" y="-1" rx="0" ry="0" opacity="1"
|
|
||||||
stroke-width="0" stroke="none" stroke-dasharray="0" fill="#fff"></rect>
|
|
||||||
</clipPath>
|
|
||||||
<clipPath id="forecastMask3qnjc9lg"></clipPath>
|
|
||||||
<clipPath id="nonForecastMask3qnjc9lg"></clipPath>
|
|
||||||
<clipPath id="gridRectMarkerMask3qnjc9lg">
|
|
||||||
<rect id="SvgjsRect1789" width="160" height="182" x="-2" y="-2" rx="0" ry="0" opacity="1"
|
|
||||||
stroke-width="0" stroke="none" stroke-dasharray="0" fill="#fff"></rect>
|
|
||||||
</clipPath>
|
|
||||||
<linearGradient id="SvgjsLinearGradient1794" x1="0" y1="1" x2="1" y2="1">
|
|
||||||
<stop id="SvgjsStop1795" stop-opacity="0.1" stop-color="rgba(8,102,255,0.1)" offset="0">
|
|
||||||
</stop>
|
|
||||||
<stop id="SvgjsStop1796" stop-opacity="1" stop-color="rgba(0,0,0,1)" offset="1"></stop>
|
|
||||||
<stop id="SvgjsStop1797" stop-opacity="1" stop-color="rgba(0,0,0,1)" offset="1"></stop>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="SvgjsLinearGradient1804" x1="0" y1="1" x2="1" y2="1">
|
|
||||||
<stop id="SvgjsStop1805" stop-opacity="1" stop-color="rgba(8,102,255,1)" offset="0">
|
|
||||||
</stop>
|
|
||||||
<stop id="SvgjsStop1806" stop-opacity="1" stop-color="rgba(252,24,90,1)" offset="1">
|
|
||||||
</stop>
|
|
||||||
<stop id="SvgjsStop1807" stop-opacity="1" stop-color="rgba(252,24,90,1)" offset="1">
|
|
||||||
</stop>
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<g id="SvgjsG1790" class="apexcharts-radialbar">
|
|
||||||
<g id="SvgjsG1791">
|
|
||||||
<g id="SvgjsG1792" class="apexcharts-tracks">
|
|
||||||
<g id="SvgjsG1793" class="apexcharts-radialbar-track apexcharts-track" rel="1">
|
|
||||||
<path id="apexcharts-radialbarTrack-0"
|
|
||||||
d="M 23.999529440199204 103.18083296600864 A 59.5829268292683 59.5829268292683 0 1 1 132.0004705598008 103.18083296600865"
|
|
||||||
fill="none" fill-opacity="1" stroke="rgba(0, 0, 0, 0.1)" stroke-opacity="1"
|
|
||||||
stroke-linecap="round" stroke-width="4.696536585365855" stroke-dasharray="0"
|
|
||||||
class="apexcharts-radialbar-area"
|
|
||||||
data:pathOrig="M 23.999529440199204 103.18083296600864 A 59.5829268292683 59.5829268292683 0 1 1 132.0004705598008 103.18083296600865">
|
|
||||||
</path>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<g id="SvgjsG1799">
|
|
||||||
<g id="SvgjsG1803" class="apexcharts-series apexcharts-radial-series"
|
|
||||||
seriesName="TotalxOrders" rel="1" data:realIndex="0">
|
|
||||||
<path id="SvgjsPath1808"
|
|
||||||
d="M 23.999529440199204 103.18083296600864 A 59.5829268292683 59.5829268292683 0 0 1 131.55277989522526 51.88056403680397"
|
|
||||||
fill="none" fill-opacity="0.85" stroke="url(#SvgjsLinearGradient1804)"
|
|
||||||
stroke-opacity="1" stroke-linecap="round" stroke-width="7.009756097560977"
|
|
||||||
stroke-dasharray="0" class="apexcharts-radialbar-area apexcharts-radialbar-slice-0"
|
|
||||||
data:angle="179" data:value="78" index="0" j="0"
|
|
||||||
data:pathOrig="M 23.999529440199204 103.18083296600864 A 59.5829268292683 59.5829268292683 0 0 1 131.55277989522526 51.88056403680397">
|
|
||||||
</path>
|
|
||||||
</g>
|
|
||||||
<circle id="SvgjsCircle1800" r="57.23465853658537" cx="78" cy="78"
|
|
||||||
class="apexcharts-radialbar-hollow" fill="transparent"></circle>
|
|
||||||
<g id="SvgjsG1801" class="apexcharts-datalabels-group"
|
|
||||||
transform="translate(0, 0) scale(1)" style="opacity: 1;"><text id="SvgjsText1802"
|
|
||||||
font-family="Helvetica, Arial, sans-serif" x="78" y="88" text-anchor="middle"
|
|
||||||
dominant-baseline="auto" font-size="24px" font-weight="400" fill="#111111"
|
|
||||||
class="apexcharts-text apexcharts-datalabel-value"
|
|
||||||
style="font-family: Helvetica, Arial, sans-serif;">78%</text></g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<line id="SvgjsLine1809" x1="0" y1="0" x2="156" y2="0" stroke="#b6b6b6" stroke-dasharray="0"
|
|
||||||
stroke-width="1" stroke-linecap="butt" class="apexcharts-ycrosshairs"></line>
|
|
||||||
<line id="SvgjsLine1810" x1="0" y1="0" x2="156" y2="0" stroke-dasharray="0" stroke-width="0"
|
|
||||||
stroke-linecap="butt" class="apexcharts-ycrosshairs-hidden"></line>
|
|
||||||
</g>
|
|
||||||
</svg></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="text-center">
|
|
||||||
<p class="mb-0">24K users increased from last month</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-xl-12">
|
|
||||||
<div class="card rounded-4 mb-0">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="d-flex align-items-center gap-3 mb-2">
|
|
||||||
<div class="">
|
|
||||||
<h2 class="mb-0">$65,129</h2>
|
|
||||||
</div>
|
|
||||||
<div class="">
|
|
||||||
<p
|
|
||||||
class="dash-lable d-flex align-items-center gap-1 rounded mb-0 bg-success text-success bg-opacity-10">
|
|
||||||
<span class="material-icons-outlined fs-6">arrow_upward</span>8.6%
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p class="mb-0">Sales This Year</p>
|
|
||||||
<div class="mt-4">
|
|
||||||
<p class="mb-2 d-flex align-items-center justify-content-between">285 left to Goal<span
|
|
||||||
class="">78%</span></p>
|
|
||||||
<div class="progress w-100" style="height: 7px;">
|
|
||||||
<div class="progress-bar bg-primary" style="width: 65%"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- series watchtime -->
|
||||||
|
<!-- <div class="card rounded-4">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex gap-2 mb-4">
|
||||||
|
<div
|
||||||
|
class="wh-48 d-flex bg-danger text-danger bg-opacity-10 align-items-center justify-content-center rounded-circle"
|
||||||
|
style="min-width: 48px;">
|
||||||
|
<span class="material-icons-outlined">tv</span>
|
||||||
|
</div>
|
||||||
|
<h5 class="mb-0 d-flex align-items-center gap-2">
|
||||||
|
Total Time Spent Watching Tv-Series
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex align-items-start justify-content">
|
||||||
|
<div class="d-flex flex-column align-items-start gap-1">
|
||||||
|
<h5 class="mb-0 time-color">{{ watchTime.allTime.series | number }} minutes</h5>
|
||||||
|
<p class="mb-0">and it is</p>
|
||||||
|
<h5 class="mb-0 time-color">{{ watchTime.allTime.series | minutesFormat:'hours' | number }} hours</h5>
|
||||||
|
<p class="mb-0">which is about {{watchTime.allTime.series | minutesFormat:'days'}} days.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
</div><!--end row-->
|
|
||||||
</div>
|
|
||||||
</div>
|
<!-- watch history graph -->
|
||||||
</div>
|
|
||||||
<div class="col-12 col-xl-7 col-xxl-8 d-flex">
|
<div class="col-12 col-xl-7 col-xxl-8 d-flex">
|
||||||
<div class="card w-100 rounded-4">
|
<div class="card w-100 rounded-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex align-items-start justify-content-between mb-3">
|
<div class="d-flex align-items-start justify-content-between mb-3">
|
||||||
<div class="">
|
<div class="">
|
||||||
<h5 class="mb-0 fw-bold">{{watchCount.year}} Watch Stats</h5>
|
<h5 class="mb-0 fw-bold">{{watchCount.year}} Watch History</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<a href="javascript:;" class="dropdown-toggle-nocaret options dropdown-toggle" data-bs-toggle="dropdown">
|
<a href="javascript:;" class="dropdown-toggle-nocaret options dropdown-toggle" data-bs-toggle="dropdown">
|
||||||
@@ -328,5 +250,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
|
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
|
||||||
@@ -4,6 +4,9 @@ import { EntrySeenService } from '../../core/services/entry-seen.service';
|
|||||||
import { LibraryService } from '../../core/services/library.service';
|
import { LibraryService } from '../../core/services/library.service';
|
||||||
import { EpisodeSeenService } from '../../core/services/episode-seen.service';
|
import { EpisodeSeenService } from '../../core/services/episode-seen.service';
|
||||||
import { forkJoin } from 'rxjs';
|
import { forkJoin } from 'rxjs';
|
||||||
|
import { StatisticsService } from '../../core/services/statistics.service';
|
||||||
|
import { WatchTime } from '../../shared/models/statistics/watchTime.model';
|
||||||
|
import { WatchCount } from '../../shared/models/statistics/watchCount.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home-page',
|
selector: 'app-home-page',
|
||||||
@@ -24,23 +27,32 @@ export class HomeComponent implements OnInit {
|
|||||||
};
|
};
|
||||||
|
|
||||||
yearlyChart: any;
|
yearlyChart: any;
|
||||||
watchCount: {
|
watchCount: WatchCount = {
|
||||||
movies: number[];
|
year: 0,
|
||||||
series: number[];
|
|
||||||
moviesTotal: number;
|
|
||||||
seriesTotal: number;
|
|
||||||
year: number;
|
|
||||||
} = {
|
|
||||||
movies: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
movies: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
series: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
series: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
moviesTotal: 0,
|
moviesTotal: 0,
|
||||||
seriesTotal: 0,
|
seriesTotal: 0,
|
||||||
year: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watchTime: WatchTime = {
|
||||||
|
allTime: {
|
||||||
|
series: 0,
|
||||||
|
movies: 0,
|
||||||
|
},
|
||||||
|
yearly: {
|
||||||
|
year: 0,
|
||||||
|
series: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
movies: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
moviesTotal: 0,
|
||||||
|
seriesTotal: 0,
|
||||||
|
},
|
||||||
|
} as WatchTime;
|
||||||
|
|
||||||
|
minutesAge = 0;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private entrySeenService: EntrySeenService,
|
private statisticsService: StatisticsService,
|
||||||
private episodeSeenService: EpisodeSeenService,
|
|
||||||
private libraryService: LibraryService
|
private libraryService: LibraryService
|
||||||
) {
|
) {
|
||||||
console.log('hey im home');
|
console.log('hey im home');
|
||||||
@@ -53,38 +65,39 @@ export class HomeComponent implements OnInit {
|
|||||||
// ? get yearly watch stats
|
// ? get yearly watch stats
|
||||||
let year: number = new Date().getFullYear();
|
let year: number = new Date().getFullYear();
|
||||||
this.watchCount.year = year;
|
this.watchCount.year = year;
|
||||||
this.getYearlyWatchHistoryStats();
|
this.getYearlyWatchCount();
|
||||||
|
this.getWatchTime();
|
||||||
|
|
||||||
|
this.minutesAge =
|
||||||
|
(new Date().getTime() - new Date('2000-08-07').getTime()) / 1000 / 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeYear(year: number) {
|
changeYear(year: number) {
|
||||||
// TODO implement this in the view
|
// TODO implement this in the view
|
||||||
this.watchCount.year = year;
|
this.watchCount.year = year;
|
||||||
console.log(`Year set to: `, this.watchCount.year);
|
console.log(`Year set to: `, this.watchCount.year);
|
||||||
this.getYearlyWatchHistoryStats();
|
this.getYearlyWatchCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getYearlyWatchHistoryStats() {
|
async getYearlyWatchCount() {
|
||||||
let moviesObs = this.entrySeenService.getYearlyStats(this.watchCount.year);
|
let watchCountObs = this.statisticsService
|
||||||
let seriesObs = this.episodeSeenService.getYearlyStats(
|
.fetchYearlyWatchCount(this.watchCount.year)
|
||||||
this.watchCount.year
|
.subscribe({
|
||||||
);
|
next: (wc) => {
|
||||||
|
// console.log(`results: `, movies, series);
|
||||||
const forkObs = forkJoin([moviesObs, seriesObs]).subscribe({
|
|
||||||
next: ([movies, series]) => {
|
|
||||||
console.log(`results: `, movies, series);
|
|
||||||
this.watchCount.moviesTotal = 0;
|
this.watchCount.moviesTotal = 0;
|
||||||
this.watchCount.seriesTotal = 0;
|
this.watchCount.seriesTotal = 0;
|
||||||
this.watchCount.movies = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
this.watchCount.movies = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
this.watchCount.series = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
this.watchCount.series = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
for (let i = 0; i < movies.length; i++) {
|
for (let i = 0; i < wc.movies.length; i++) {
|
||||||
this.watchCount.movies[movies[i].month - 1] = movies[i].count;
|
this.watchCount.movies[wc.movies[i].month - 1] = wc.movies[i].count;
|
||||||
this.watchCount.moviesTotal += movies[i].count;
|
this.watchCount.moviesTotal += wc.movies[i].count;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < series.length; i++) {
|
for (let i = 0; i < wc.series.length; i++) {
|
||||||
this.watchCount.series[series[i].month - 1] = series[i].count;
|
this.watchCount.series[wc.series[i].month - 1] = wc.series[i].count;
|
||||||
this.watchCount.seriesTotal += series[i].count;
|
this.watchCount.seriesTotal += wc.series[i].count;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
@@ -95,6 +108,44 @@ export class HomeComponent implements OnInit {
|
|||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
},
|
},
|
||||||
|
complete: () => {
|
||||||
|
watchCountObs.unsubscribe();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async getWatchTime() {
|
||||||
|
const thisYear = new Date().getFullYear();
|
||||||
|
let allTimeObs = this.statisticsService.fetchAllTimeTotalWatchTime();
|
||||||
|
let yearlyObs = this.statisticsService.fetchYearlyTotalWatchTime(thisYear);
|
||||||
|
|
||||||
|
const forkObs = forkJoin([allTimeObs, yearlyObs]).subscribe({
|
||||||
|
next: ([allTime, yearly]) => {
|
||||||
|
// console.log(`results: `, allTime, yearly);
|
||||||
|
this.watchTime.allTime.series = allTime.series;
|
||||||
|
this.watchTime.allTime.movies = allTime.movies;
|
||||||
|
this.watchTime.allTime.total =
|
||||||
|
Number.parseInt(allTime.series) + Number.parseInt(allTime.movies);
|
||||||
|
|
||||||
|
this.watchTime.yearly.year = thisYear;
|
||||||
|
|
||||||
|
for (let i = 0; i < yearly.series.length; i++) {
|
||||||
|
this.watchTime.yearly.series[yearly.series[i].month - 1] =
|
||||||
|
yearly.series[i].watchTime;
|
||||||
|
this.watchTime.yearly.seriesTotal += yearly.series[i].watchTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < yearly.movies.length; i++) {
|
||||||
|
this.watchTime.yearly.movies[yearly.movies[i].month - 1] =
|
||||||
|
yearly.movies[i].watchTime;
|
||||||
|
this.watchTime.yearly.moviesTotal += yearly.movies[i].watchTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(this.watchTime);
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.log(error);
|
||||||
|
},
|
||||||
complete: () => {
|
complete: () => {
|
||||||
forkObs.unsubscribe();
|
forkObs.unsubscribe();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user