Skip to content

Commit

Permalink
remove dynamic filters for realtime + fix precision issues (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirch1 authored Sep 27, 2021
1 parent 1354324 commit e4ca3de
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<div class="kFilterContainer kOverrideFAIcons">
<div class="kFilterContainerRow">
<div class="kFilterContainerCol">
<app-webcast-device-filter [dateFilter]="_dateFilter"
<!--app-webcast-device-filter [dateFilter]="_dateFilter"
[selectedFilters]="_selectedValues['devices']"
[filterConfig]="filterConfig"
(itemSelected)="_onItemSelected($event, 'devices')"
[isRealTime]="true"
(itemUnselected)="_onItemUnselected($event, 'devices')"></app-webcast-device-filter>
(itemUnselected)="_onItemUnselected($event, 'devices')"></app-webcast-device-filter-->

<app-webcast-browser-filter [dateFilter]="_dateFilter"
[filterConfig]="filterConfig"
Expand All @@ -34,21 +34,22 @@
[predefinedBrowsers]="predefinedBrowsers"
(itemUnselected)="_onItemUnselected($event, 'browser')"></app-webcast-browser-filter>

</div>
<div class="kFilterContainerCol location-filters">
<app-webcast-os-filter [dateFilter]="_dateFilter"
[selectedFilters]="_selectedValues['os']"
[filterConfig]="filterConfig"
(itemSelected)="_onItemSelected($event, 'os')"
[predefinedOSs]="predefinedOSs"
(itemUnselected)="_onItemUnselected($event, 'os')"></app-webcast-os-filter>
</div>
<div class="kFilterContainerCol location-filters">
<app-location-filters [expandWidth]="!showAutocompleteGroup"

<!--app-location-filters [expandWidth]="!showAutocompleteGroup"
[filterWarning]="locationFiltersWarning"
[dateFilter]="_dateFilter"
[filterConfig]="filterConfig"
[selectedFilters]="_selectedValues['location']"
[isRealTime]="true"
(itemSelected)="_onItemSelected($event, 'location')"></app-location-filters>
(itemSelected)="_onItemSelected($event, 'location')"></app-location-filters-->
</div>
<div class="kFilterContainerCol">
<app-owners-filter [selectedFilters]="_selectedValues['users']"
Expand Down
4 changes: 0 additions & 4 deletions src/app/modules/entry-live/entry-live-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ export class EntryLiveViewComponent implements OnInit, OnDestroy {

if (this._timeSelector) {
this._timeSelector.updateDataRanges(false);
this._selectedDateLabelRange = {
startDate: Math.floor(this._timeSelector._endDate.getTime() / 1000),
endDate: Math.floor(this._timeSelector._endDate.getTime() / 1000),
} as DateChangeEvent;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class DiscoveryChartComponent implements OnDestroy{
}

private shouldNormalize(metric: string): boolean {
const normalizedMetrics = ['view_unique_audience', 'viewers', 'view_unique_audience_dvr', 'viewers_dvr', 'view_unique_engaged_users', 'viewers_engagement'];
const normalizedMetrics = ['view_unique_audience', 'viewers', 'view_unique_audience_dvr', 'viewers_dvr', 'view_unique_engaged_users', 'viewers_engagement', 'avg_view_segment_download_time_sec', 'avg_view_manifest_download_time_sec'];
return normalizedMetrics.indexOf(metric) > -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class LiveDiscoveryConfig extends ReportDataBaseConfig {
format: value => parseFloat(value).toFixed(2),
colors: ['#BD93F8'],
graphType: GraphType.line,
graphTooltip: value => `${this._translate.instant('app.entryLive.discovery.avg_view_segment_download_time_sec')}: ${ReportHelper.numberOrZero(value)} Seconds`,
graphTooltip: value => `${this._translate.instant('app.entryLive.discovery.avg_view_segment_download_time_sec')}: ${ReportHelper.numberOrZero(value, true, 2)} Seconds`,
units: () => 'Seconds',
sortOrder: 8,
group: 'qualityOfService',
Expand All @@ -105,7 +105,7 @@ export class LiveDiscoveryConfig extends ReportDataBaseConfig {
format: value => parseFloat(value).toFixed(2),
colors: ['#8A54D7'],
graphType: GraphType.line,
graphTooltip: value => `${this._translate.instant('app.entryLive.discovery.avg_view_manifest_download_time_sec')}: ${ReportHelper.numberOrZero(value)} Seconds`,
graphTooltip: value => `${this._translate.instant('app.entryLive.discovery.avg_view_manifest_download_time_sec')}: ${ReportHelper.numberOrZero(value, true, 2)} Seconds`,
units: () => 'Seconds',
sortOrder: 9,
group: 'qualityOfService',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export class TimeSelectorComponent implements OnDestroy {
@ViewChild(PopupWidgetComponent) _popupWidget: PopupWidgetComponent;

private _lastSelectedDateRange: DateRange; // used for revert selection
public _startDate: Date;
public _endDate: Date;
private _startDate: Date;
private _endDate: Date;
private _invalidTimes = false;

public _invalidFrom = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class DeviceFilterComponent implements OnDestroy {
// use timeout to allow updating the filter before loading the data when in context (entry / category / user / playlist)
setTimeout(() => {
this._devicesFilterService.updateDateFilter(event, () => {
// this._selectedDevices = [];
this._selectedDevices = [];
}, this._isRealTime);
}, 0);
}
Expand Down
30 changes: 15 additions & 15 deletions src/app/shared/services/report-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ export class ReportHelper {
// use en-US format always to have consistent formatting
return parseFloat(x).toLocaleString('en-US', { maximumSignificantDigits: 20 });
}

static percents(x: any, round = true, maxHundred = false, addUnits = true, precision = 1): string {
x = parseFloat(x) * 100;
x = maxHundred && x > 100 ? 100 : x;
x = round ? Math.round(x) : x;
return !isNaN(x) ? `${this.numberWithCommas(x.toFixed(precision))}${addUnits ? '%' : ''}` : 'N/A';
}

static numberOrNA(x: any): string {
return x.length ? ReportHelper.numberWithCommas(Math.round(parseFloat(x))) : 'N/A';
}
static numberOrZero(x: any, round = true): string {

static numberOrZero(x: any, round = true, precision = 1): string {
x = parseFloat(x);
if (isNaN(x)) {
return '0';
} else {
x = x % 1 === 0
? round ? Math.round(x) : x
: x.toFixed(1);
: x.toFixed(precision);

return ReportHelper.numberWithCommas(x);
}
}

static minutes(x: number): number {
x = typeof x === 'number' ? x : parseFloat(x);
x = !isNaN(x) ? x : 0;

return x / 60000;
}

static integerOrZero(x: any, round = true): string {
x = parseInt(x);
return this.numberOrZero(x, round);
}

static time(x: any): string {
if (!x.length) {
return '00:00';
Expand All @@ -52,20 +52,20 @@ export class ReportHelper {
const wholeSeconds = Math.floor((numValue - (wholeMinutes * 60000)) / 1000);
const secondsText = wholeSeconds < 10 ? '0' + wholeSeconds.toString() : wholeSeconds.toString();
let formattedTime = wholeMinutes.toString() + ':' + secondsText;

if (parseFloat(x) < 0) {
formattedTime = '-' + formattedTime;
}
return formattedTime;
}

static underscoreToSpace(x: string): string {
return x.replace('_', ' ');
}

static format(param: string, value: string): string {
let result: string = value;

switch (param) {
case 'count_plays':
case 'count_plays_25':
Expand Down Expand Up @@ -123,7 +123,7 @@ export class ReportHelper {
const wholeSeconds = Math.floor((numValue - (wholeMinutes * 60000)) / 1000);
const secondsText = wholeSeconds < 10 ? '0' + wholeSeconds.toString() : wholeSeconds.toString();
let formattedTime = wholeMinutes.toString() + ':' + secondsText;

if (parseFloat(value) < 0) {
formattedTime = '-' + formattedTime;
}
Expand All @@ -135,7 +135,7 @@ export class ReportHelper {
// replace '_' with space
result = value.replace('_', ' ');
break;

}
return result;
}
Expand Down

0 comments on commit e4ca3de

Please sign in to comment.