🖌️ Formatting changes

This commit is contained in:
2024-10-18 13:19:57 -04:00
parent 4ffad69c44
commit 55e0ce6d36

View File

@@ -62,12 +62,8 @@ export default class SocketService extends Service {
if (active > 0 || paused > 0 || waiting > 0) { if (active > 0 || paused > 0 || waiting > 0) {
// 3. Get job counts // 3. Get job counts
const completedJobCount = await pubClient.get( const completedJobCount = await pubClient.get("completedJobCount");
"completedJobCount" const failedJobCount = await pubClient.get("failedJobCount");
);
const failedJobCount = await pubClient.get(
"failedJobCount"
);
// 4. Send the counts to the active socket.io session // 4. Send the counts to the active socket.io session
await this.broker.call("socket.broadcast", { await this.broker.call("socket.broadcast", {
@@ -84,14 +80,9 @@ export default class SocketService extends Service {
} }
} }
} catch (err) { } catch (err) {
throw new MoleculerError( throw new MoleculerError(err, 500, "SESSION_ID_NOT_FOUND", {
err,
500,
"SESSION_ID_NOT_FOUND",
{
data: sessionId, data: sessionId,
} });
);
} }
}, },
@@ -102,11 +93,7 @@ export default class SocketService extends Service {
}> }>
) => { ) => {
const { queueAction } = ctx.params; const { queueAction } = ctx.params;
await this.broker.call( await this.broker.call("jobqueue.toggle", { action: queueAction }, {});
"jobqueue.toggle",
{ action: queueAction },
{}
);
}, },
importSingleIssue: async (ctx: Context<{}>) => { importSingleIssue: async (ctx: Context<{}>) => {
console.info("AirDC++ finished a download -> "); console.info("AirDC++ finished a download -> ");
@@ -119,9 +106,14 @@ export default class SocketService extends Service {
}, },
// AirDCPP Socket actions // AirDCPP Socket actions
getBundles: { getBundles: {
async handler(ctx) { async handler(
ctx: Context<{
comicObjectId: string;
}>
) {
// get bundles bitch // get bundles bitch
} // 1. Get the comic object Id
},
}, },
search: { search: {
params: { params: {
@@ -134,10 +126,7 @@ export default class SocketService extends Service {
const ADCPPSocket = new AirDCPPSocket(config); const ADCPPSocket = new AirDCPPSocket(config);
try { try {
await ADCPPSocket.connect(); await ADCPPSocket.connect();
const instance = await ADCPPSocket.post( const instance = await ADCPPSocket.post("search", query);
"search",
query
);
// Send the instance to the client // Send the instance to the client
await namespacedInstance.emit("searchInitiated", { await namespacedInstance.emit("searchInitiated", {
@@ -150,10 +139,7 @@ export default class SocketService extends Service {
`search_result_added`, `search_result_added`,
(groupedResult) => { (groupedResult) => {
console.log(JSON.stringify(groupedResult, null, 4)); console.log(JSON.stringify(groupedResult, null, 4));
namespacedInstance.emit( namespacedInstance.emit("searchResultAdded", groupedResult);
"searchResultAdded",
groupedResult
);
}, },
instance.id instance.id
); );
@@ -162,10 +148,7 @@ export default class SocketService extends Service {
`search`, `search`,
`search_result_updated`, `search_result_updated`,
(updatedResult) => { (updatedResult) => {
namespacedInstance.emit( namespacedInstance.emit("searchResultUpdated", updatedResult);
"searchResultUpdated",
updatedResult
);
}, },
instance.id instance.id
); );
@@ -175,47 +158,30 @@ export default class SocketService extends Service {
`search_hub_searches_sent`, `search_hub_searches_sent`,
async (searchInfo) => { async (searchInfo) => {
await this.sleep(5000); await this.sleep(5000);
const currentInstance = const currentInstance = await ADCPPSocket.get(
await ADCPPSocket.get(
`search/${instance.id}` `search/${instance.id}`
); );
// Send the instance to the client // Send the instance to the client
await namespacedInstance.emit( await namespacedInstance.emit("searchesSent", {
"searchesSent",
{
searchInfo, searchInfo,
} });
);
if (currentInstance.result_count === 0) { if (currentInstance.result_count === 0) {
console.log("No more search results."); console.log("No more search results.");
namespacedInstance.emit( namespacedInstance.emit("searchComplete", {
"searchComplete", message: "No more search results.",
{ });
message:
"No more search results.",
}
);
} }
}, },
instance.id instance.id
); );
// Perform the actual search // Perform the actual search
await ADCPPSocket.post( await ADCPPSocket.post(`search/${instance.id}/hub_search`, query);
`search/${instance.id}/hub_search`,
query
);
} catch (error) { } catch (error) {
await namespacedInstance.emit( await namespacedInstance.emit("searchError", error.message);
"searchError", throw new MoleculerError("Search failed", 500, "SEARCH_FAILED", {
error.message error,
); });
throw new MoleculerError(
"Search failed",
500,
"SEARCH_FAILED",
{ error }
);
} finally { } finally {
// await ADCPPSocket.disconnect(); // await ADCPPSocket.disconnect();
} }
@@ -266,10 +232,7 @@ export default class SocketService extends Service {
"Download and metadata update successful", "Download and metadata update successful",
bundleDBImportResult bundleDBImportResult
); );
this.broker.emit( this.broker.emit("downloadCompleted", bundleDBImportResult);
"downloadCompleted",
bundleDBImportResult
);
return bundleDBImportResult; return bundleDBImportResult;
} else { } else {
throw new Error( throw new Error(
@@ -278,12 +241,9 @@ export default class SocketService extends Service {
} }
} catch (error) { } catch (error) {
this.broker.emit("downloadError", error.message); this.broker.emit("downloadError", error.message);
throw new MoleculerError( throw new MoleculerError("Download failed", 500, "DOWNLOAD_FAILED", {
"Download failed", error,
500, });
"DOWNLOAD_FAILED",
{ error }
);
} finally { } finally {
// await ADCPPSocket.disconnect(); // await ADCPPSocket.disconnect();
} }
@@ -303,10 +263,7 @@ export default class SocketService extends Service {
"queue", "queue",
"queue_bundle_tick", "queue_bundle_tick",
(tickData) => { (tickData) => {
console.log( console.log("Received tick data: ", tickData);
"Received tick data: ",
tickData
);
this.io.emit("bundleTickUpdate", tickData); this.io.emit("bundleTickUpdate", tickData);
}, },
null null