mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-14 01:37:48 -05:00
different Loop style
This commit is contained in:
@@ -25,7 +25,9 @@ async function get_calls(query, numResults, res) {
|
|||||||
|
|
||||||
const sort = { length: -1 };
|
const sort = { length: -1 };
|
||||||
try {
|
try {
|
||||||
for await (const item of Call.find(query.filter, fields).sort(sort).limit(numResults)) {
|
const items = await Call.find(query.filter, fields).sort(sort).limit(numResults);
|
||||||
|
for (var i=0; i < items.length; i++) {
|
||||||
|
const item = items[i];
|
||||||
call = {
|
call = {
|
||||||
_id: item._id.toHexString(),
|
_id: item._id.toHexString(),
|
||||||
talkgroupNum: item.talkgroupNum,
|
talkgroupNum: item.talkgroupNum,
|
||||||
@@ -40,11 +42,10 @@ async function get_calls(query, numResults, res) {
|
|||||||
calls.push(call);
|
calls.push(call);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.contentType('json');
|
res.json({
|
||||||
res.send(JSON.stringify({
|
|
||||||
calls: calls,
|
calls: calls,
|
||||||
direction: query.direction
|
direction: query.direction
|
||||||
}));
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn("Error - get_calls() Could not find item " + err + " filter: " + query.filter);
|
console.warn("Error - get_calls() Could not find item " + err + " filter: " + query.filter);
|
||||||
res.send(404, 'Sorry, we cannot find that!');
|
res.send(404, 'Sorry, we cannot find that!');
|
||||||
@@ -111,7 +112,7 @@ async function build_filter(filter_type, code, start_time, direction, shortName,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const group = await Group.findOne({ 'shortName': shortName, '_id': ObjectId.createFromHexString(code)}).exec();
|
const group = await Group.findOne({ 'shortName': shortName, '_id': ObjectId.createFromHexString(code) }).exec();
|
||||||
if (!group) {
|
if (!group) {
|
||||||
console.warn("[" + shortName + "] Error - build_filter() group is null " + err);
|
console.warn("[" + shortName + "] Error - build_filter() group is null " + err);
|
||||||
res.contentType('json');
|
res.contentType('json');
|
||||||
@@ -173,7 +174,7 @@ exports.get_card = async function (req, res) {
|
|||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const item = await Call.findById(o_id).exec();
|
const item = await Call.findById(o_id).exec();
|
||||||
|
|
||||||
//console.log(util.inspect(item));
|
//console.log(util.inspect(item));
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ function addSystemClients(req, res, next) {
|
|||||||
|
|
||||||
|
|
||||||
/*------ CALLS ----------*/
|
/*------ CALLS ----------*/
|
||||||
/*
|
|
||||||
app.get('/card/:id', calls.get_card);
|
app.get('/card/:id', calls.get_card);
|
||||||
app.post('/add_star/:id', calls.add_star);
|
app.post('/add_star/:id', calls.add_star);
|
||||||
app.post('/remove_star/:id', calls.remove_star);
|
app.post('/remove_star/:id', calls.remove_star);
|
||||||
@@ -106,7 +106,7 @@ app.get('/:shortName/calls/next', calls.get_next_calls);
|
|||||||
app.get('/:shortName/calls/newer', calls.get_newer_calls);
|
app.get('/:shortName/calls/newer', calls.get_newer_calls);
|
||||||
app.get('/:shortName/calls/older', calls.get_older_calls);
|
app.get('/:shortName/calls/older', calls.get_older_calls);
|
||||||
app.get('/:shortName/calls/:time/older', calls.get_iphone_calls);
|
app.get('/:shortName/calls/:time/older', calls.get_iphone_calls);
|
||||||
app.get('/:shortName/calls', calls.get_calls); */
|
app.get('/:shortName/calls', calls.get_calls);
|
||||||
|
|
||||||
|
|
||||||
/*------ UPLOADS ---------- upload.single('call'), uploads.upload,*/
|
/*------ UPLOADS ---------- upload.single('call'), uploads.upload,*/
|
||||||
@@ -125,9 +125,9 @@ app.get('/:shortName/groups', groups.get_groups);
|
|||||||
|
|
||||||
|
|
||||||
/*------ EVENTS ----------*/
|
/*------ EVENTS ----------*/
|
||||||
/*app.post('/events', events.addNewEvent);
|
app.post('/events', events.addNewEvent);
|
||||||
app.get('/events', events.getEvents);
|
app.get('/events', events.getEvents);
|
||||||
app.get('/events/:id', events.getEvent);*/
|
app.get('/events/:id', events.getEvent);
|
||||||
|
|
||||||
/*------ STATS ----------*/
|
/*------ STATS ----------*/
|
||||||
//app.get('/:shortName/stats', stats.get_stats);
|
//app.get('/:shortName/stats', stats.get_stats);
|
||||||
|
|||||||
Reference in New Issue
Block a user