From 093ba42ff4c91b0770daf481966d81fb2b9aadf5 Mon Sep 17 00:00:00 2001 From: Chrystian Huot Date: Thu, 23 Jan 2020 10:56:55 -0500 Subject: [PATCH] RdioScannerCalls index improvement and minor bug fix to search pane --- .../rdio-scanner/rdio-scanner.component.ts | 12 ++++-- ...91126135515-optimize-rdio-scanner-calls.js | 2 +- ...00123094105-optimize-rdio-scanner-calls.js | 38 +++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 server/migrations/20200123094105-optimize-rdio-scanner-calls.js diff --git a/client/src/app/components/rdio-scanner/rdio-scanner.component.ts b/client/src/app/components/rdio-scanner/rdio-scanner.component.ts index c6910d7..72e505a 100644 --- a/client/src/app/components/rdio-scanner/rdio-scanner.component.ts +++ b/client/src/app/components/rdio-scanner/rdio-scanner.component.ts @@ -1,4 +1,4 @@ -import { Component, HostListener, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { Component, EventEmitter, HostListener, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { MatPaginator } from '@angular/material/paginator'; import { BehaviorSubject, Subscription } from 'rxjs'; @@ -35,6 +35,8 @@ interface RdioScannerSelection { templateUrl: './rdio-scanner.component.html', }) export class AppRdioScannerComponent implements OnDestroy, OnInit { + @Output() readonly live = new EventEmitter(); + get call() { return this._call; } get callHistory() { return this._callHistory; } get callPrevious() { return this._callPrevious; } @@ -297,6 +299,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit { this.stop(); } + + this.live.emit(status); } loadAndPlay(call: RdioScannerCall): void { @@ -310,6 +314,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit { } ngOnDestroy(): void { + this.live.complete(); + this.unsubscribeLivefeed(); this.unsubscribeSearchForm(); @@ -729,8 +735,6 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit { if (!this.searchFormSubscription) { this.searchFormSubscription = this.searchForm.valueChanges.subscribe((value) => { if (!Object.keys(value).every((key) => value[key] === lastValue[key])) { - lastValue = value; - if (value.system !== lastValue.system && value.talkgroup !== -1) { lastValue.talkgroup = -1; this.searchForm.get('talkgroup').reset(lastValue.talkgroup); @@ -739,6 +743,8 @@ export class AppRdioScannerComponent implements OnDestroy, OnInit { this.matPaginator.firstPage(); this.loadStoredCalls(value); + + lastValue = value; } }); } diff --git a/server/migrations/20191126135515-optimize-rdio-scanner-calls.js b/server/migrations/20191126135515-optimize-rdio-scanner-calls.js index a673384..1db332e 100644 --- a/server/migrations/20191126135515-optimize-rdio-scanner-calls.js +++ b/server/migrations/20191126135515-optimize-rdio-scanner-calls.js @@ -2,7 +2,7 @@ module.exports = { - up: async (queryInterface, Sequelize) => { + up: async (queryInterface) => { const transaction = await queryInterface.sequelize.transaction(); try { diff --git a/server/migrations/20200123094105-optimize-rdio-scanner-calls.js b/server/migrations/20200123094105-optimize-rdio-scanner-calls.js new file mode 100644 index 0000000..62e4492 --- /dev/null +++ b/server/migrations/20200123094105-optimize-rdio-scanner-calls.js @@ -0,0 +1,38 @@ +'use strict'; + +module.exports = { + + up: async (queryInterface) => { + const transaction = await queryInterface.sequelize.transaction(); + + try { + await queryInterface.addIndex('rdioScannerCalls', ['system'], { transaction }); + + await queryInterface.addIndex('rdioScannerCalls', ['system', 'talkgroup'], { transaction }); + + await transaction.commit(); + + } catch (err) { + await transaction.rollback(); + + throw err; + } + }, + + down: async (queryInterface) => { + const transaction = queryInterface.sequelize.transaction(); + + try { + await queryInterface.removeIndex('rdioScannerCalls', ['system'], { transaction }); + + await queryInterface.removeIndex('rdioScannerCalls', ['system', 'talkgroup'], { transaction }); + + await transaction.commit(); + + } catch (err) { + await transaction.rollback(); + + throw err; + } + }, +};