fixed some errors

This commit is contained in:
Luke Berndt
2023-07-18 20:48:09 -04:00
parent 2903fe9d03
commit 4ceb65cc02
4 changed files with 17 additions and 14 deletions

View File

@@ -24,7 +24,6 @@ const build_call_list = (items) => {
}; };
calls.push(call); calls.push(call);
} }
console.log("Finished Items is: " + items.length + " long and Calls is: " + calls.length)
return calls; return calls;
} }
@@ -46,25 +45,19 @@ async function get_calls(query, numResults, middleDate, res) {
const sort = { length: -1 }; const sort = { length: -1 };
try { try {
console.log(query.filter);
const items = await Call.find(query.filter, fields).sort(query.sort_order).limit(numResults); const items = await Call.find(query.filter, fields).sort(query.sort_order).limit(numResults);
const refined_items = build_call_list(items); const refined_items = build_call_list(items);
//calls.concat(refined_items);
calls.push(...refined_items); calls.push(...refined_items);
console.log(calls);
// if we are loading a list of calls around a specific Call ID, we want to load call before and after that call, so we call it twice. // if we are loading a list of calls around a specific Call ID, we want to load call before and after that call, so we call it twice.
if (middleDate) { if (middleDate) {
query.filter.time = { query.filter.time = {
$gt: middleDate $gt: middleDate
}; };
console.log("doing a second query");
console.log(query.filter);
const items = await Call.find(query.filter, fields).sort(query.sort_order).limit(numResults); const items = await Call.find(query.filter, fields).sort(query.sort_order).limit(numResults);
const refined_items = build_call_list(items); const refined_items = build_call_list(items);
calls.push(...refined_items); calls.push(...refined_items);
console.log(calls);
//calls.concat(refined_items);
} }
res.json({ res.json({
calls: calls, calls: calls,
@@ -80,9 +73,10 @@ async function get_calls(query, numResults, middleDate, res) {
async function build_filter(filter_type, code, start_time, direction, shortName, numResults, starred, res) { async function build_filter(filter_type, code, start_time, direction, shortName, numResults, starred, res) {
var filter = {}; var filter = {};
var query = {}; var query = {};
var start = new Date(start_time);
if (start_time) { if (start_time) {
var start = new Date(start_time);
if (direction == 'newer') { if (direction == 'newer') {
filter.time = { filter.time = {
$gt: start $gt: start

View File

@@ -265,6 +265,7 @@ function Calls(props) {
filterTalkgroups: [], filterTalkgroups: [],
filterGroupId: false, filterGroupId: false,
filterStarred: false, filterStarred: false,
filterCallId: false,
shortName: shortName shortName: shortName
}; };
@@ -288,6 +289,7 @@ function Calls(props) {
if (uri.hasOwnProperty('call-id')) { if (uri.hasOwnProperty('call-id')) {
const _id = uri['call-id']; const _id = uri['call-id'];
setInitialCallId(_id); setInitialCallId(_id);
filter.filterCallId = false;
setAutoPlay(false); setAutoPlay(false);
setLive(false); setLive(false);
if (!urlOptions) setUrlOptions(true); if (!urlOptions) setUrlOptions(true);

View File

@@ -12,6 +12,7 @@ const initialState = {
filterGroupId: false, filterGroupId: false,
filterDate: false, filterDate: false,
filterStarred: false, filterStarred: false,
filterCallId: false,
currentCallId: false, currentCallId: false,
playlist: [], playlist: [],
live: false, live: false,
@@ -36,6 +37,9 @@ export const callPlayerSlice = createSlice({
setCurrentCallId: (state, action) => { setCurrentCallId: (state, action) => {
state.currentCallId = action.payload; state.currentCallId = action.payload;
}, },
setFilterCallId: (state, action) => {
state.filterCallId = action.payload;
},
setCallTime: (state, action) => { setCallTime: (state, action) => {
state.newestCallTime = action.payload; state.newestCallTime = action.payload;
state.oldestCallTime = action.payload; state.oldestCallTime = action.payload;
@@ -70,6 +74,7 @@ export const callPlayerSlice = createSlice({
state.filterTalkgroups = !action.payload.filterTalkgroups ? [] : action.payload.filterTalkgroups; state.filterTalkgroups = !action.payload.filterTalkgroups ? [] : action.payload.filterTalkgroups;
state.filterGroupId = !action.payload.filterGroupId ? false : action.payload.filterGroupId; state.filterGroupId = !action.payload.filterGroupId ? false : action.payload.filterGroupId;
state.filterDate = !action.payload.filterDate ? 0 : action.payload.filterDate; state.filterDate = !action.payload.filterDate ? 0 : action.payload.filterDate;
state.filterCallId = !action.payload.filterCallId ? false : action.payload.filterCallId;
state.shortName = !action.payload.shortName ? state.shortName : action.payload.shortName; state.shortName = !action.payload.shortName ? state.shortName : action.payload.shortName;
}, },
setLive: (state,action) => { setLive: (state,action) => {

View File

@@ -78,17 +78,19 @@ const initialState = {
var params = {}; var params = {};
var url = ""; var url = "";
const {shortName,filterType,filterGroupId, filterTalkgroups, filterStarred, filterDate} = getState().callPlayer; const {shortName,filterType,filterGroupId, filterTalkgroups, filterStarred, filterDate, filterCallId} = getState().callPlayer;
if ((typeof direction === 'string') && (typeof date === 'number')) { if ((typeof direction === 'string') && (typeof date === 'number')) {
url = url + '/' + direction; url = url + '/' + direction;
params["time"] = date; params["time"] = date;
} else { } else if (filterCallId) {
if (filterDate){ url = url + '/date'
url = url + '/date' params["time"] = filterDate;
} else if (filterDate){
url = url + '/'
params["time"] = filterDate; params["time"] = filterDate;
} }
}
if (filterStarred) { if (filterStarred) {
params["filter-starred"] = true; params["filter-starred"] = true;
} }