bugfixing
This commit is contained in:
parent
63403896ca
commit
8fa8cff73a
@ -258,6 +258,7 @@ fastify.register(async function (fastify) {
|
||||
__dirname,
|
||||
`../app/json/websocket/companies/${symbol?.toUpperCase()}.json`
|
||||
);
|
||||
|
||||
try {
|
||||
if (fs?.existsSync(filePath)) {
|
||||
const fileData = fs?.readFileSync(filePath, "utf8");
|
||||
@ -295,7 +296,9 @@ try {
|
||||
? jsonData.bp
|
||||
: avgPrice;
|
||||
|
||||
const currentDataSignature = `${jsonData?.bp}`;
|
||||
// Check if finalPrice is equal to avgPrice before sending data
|
||||
if (finalPrice - avgPrice === 0) {
|
||||
const currentDataSignature = `${finalPrice}`;
|
||||
const lastSentSignature = lastSentData[symbol];
|
||||
|
||||
if (currentDataSignature !== lastSentSignature) {
|
||||
@ -312,6 +315,7 @@ try {
|
||||
lastSentData[symbol] = currentDataSignature;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.error("File not found for ticker:", symbol);
|
||||
}
|
||||
@ -328,6 +332,7 @@ try {
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Start receiving messages from the client
|
||||
connection.socket.on("message", (message) => {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user