🔧 Added an undefined check for the results

This commit is contained in:
2024-11-18 11:07:38 -05:00
parent 4045097eb0
commit 651e3ac7bb

View File

@@ -2,7 +2,7 @@
import { Service, ServiceBroker, ServiceSchema } from "moleculer"; import { Service, ServiceBroker, ServiceSchema } from "moleculer";
import { Kafka, EachMessagePayload, logLevel } from "kafkajs"; import { Kafka, EachMessagePayload, logLevel } from "kafkajs";
import io from "socket.io-client"; import io from "socket.io-client";
import { isUndefined } from "lodash"; import { isNil, isUndefined } from "lodash";
import stringSimilarity from "string-similarity-alg"; import stringSimilarity from "string-similarity-alg";
interface SearchResult { interface SearchResult {
@@ -122,10 +122,10 @@ export default class ComicProcessorService extends Service {
await this.broker.call("socket.search", { await this.broker.call("socket.search", {
query: dcppSearchQuery, query: dcppSearchQuery,
config: { config: {
hostname: "localhost:5600", hostname: "192.168.1.119:5600",
protocol: "http", protocol: "http",
username: "user", username: "admin",
password: "pass", password: "password",
}, },
namespace: "/automated", namespace: "/automated",
}); });
@@ -257,7 +257,9 @@ export default class ComicProcessorService extends Service {
if (!this.airDCPPSearchResults.has(instanceId)) { if (!this.airDCPPSearchResults.has(instanceId)) {
this.airDCPPSearchResults.set(instanceId, []); this.airDCPPSearchResults.set(instanceId, []);
} }
this.airDCPPSearchResults.get(instanceId).push(groupedResult.result); if (!isUndefined(groupedResult?.result)) {
this.airDCPPSearchResults.get(instanceId).push(groupedResult.result);
}
}, },
); );