4 Commits

4 changed files with 971 additions and 833 deletions

View File

@@ -60,7 +60,7 @@ services:
networks:
- kafka-net
ports:
- "27017:27017"
- "127.0.0.1:27017:27017"
volumes:
- "mongodb_data:/bitnami/mongodb"
@@ -72,7 +72,7 @@ services:
networks:
- kafka-net
ports:
- "6379:6379"
- "127.0.0.1:6379:6379"
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2
@@ -88,7 +88,7 @@ services:
soft: -1
hard: -1
ports:
- "9200:9200"
- "127.0.0.1:9200:9200"
networks:
- kafka-net

1712
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -174,7 +174,7 @@ export default class LibraryService extends Service {
// Convert klaw to use a promise-based approach for better flow control
const files = await this.getComicFiles(
COMICS_DIRECTORY
process.env.COMICS_DIRECTORY
);
for (const file of files) {
console.info(
@@ -187,7 +187,6 @@ export default class LibraryService extends Service {
path.extname(file.path)
),
});
if (!comicExists) {
// Send the extraction job to the queue
await this.broker.call("jobqueue.enqueue", {
@@ -331,21 +330,51 @@ export default class LibraryService extends Service {
},
getComicsMarkedAsWanted: {
rest: "GET /getComicsMarkedAsWanted",
handler: async (ctx: Context<{}>) => {
params: {
page: { type: "number", default: 1 },
limit: { type: "number", default: 100 },
},
handler: async (
ctx: Context<{ page: number; limit: number }>
) => {
const { page, limit } = ctx.params;
this.logger.info(
`Requesting page ${page} with limit ${limit}`
);
try {
// Query to find comics where 'markEntireVolumeAsWanted' is true or 'issues' array is not empty
const wantedComics = await Comic.find({
wanted: { $exists: true },
$or: [
{ "wanted.markEntireVolumeWanted": true },
{ "wanted.issues": { $not: { $size: 0 } } },
],
});
const options = {
page,
limit,
lean: true,
};
console.log(wantedComics); // Output the found comics
return wantedComics;
const result = await Comic.paginate(
{
wanted: { $exists: true },
$or: [
{
"wanted.markEntireVolumeWanted":
true,
},
{
"wanted.issues": {
$not: { $size: 0 },
},
},
],
},
options
);
// Log the raw result from the database
this.logger.info(
"Paginate result:",
JSON.stringify(result, null, 2)
);
return result.docs; // Return just the docs array
} catch (error) {
console.error("Error finding comics:", error);
this.logger.error("Error finding comics:", error);
throw error;
}
},

View File

@@ -122,14 +122,12 @@ export default class SocketService extends Service {
params: {
query: "object",
config: "object",
namespace: "string",
},
async handler(ctx) {
console.log("a, a kanha kanha...");
const { query, config, namespace } = ctx.params;
const namespacedInstance = this.io.of(namespace || "/");
const ADCPPSocket = new AirDCPPSocket(config);
console.log("asdas", ADCPPSocket);
try {
await ADCPPSocket.connect();
const instance = await ADCPPSocket.post(
@@ -146,10 +144,13 @@ export default class SocketService extends Service {
await ADCPPSocket.addListener(
`search`,
`search_result_added`,
(groupedResult) => {
(data) => {
namespacedInstance.emit(
"searchResultAdded",
groupedResult
{
groupedResult: data,
instanceId: instance.id,
}
);
},
instance.id
@@ -158,10 +159,17 @@ export default class SocketService extends Service {
await ADCPPSocket.addListener(
`search`,
`search_result_updated`,
(updatedResult) => {
(data) => {
console.log({
updatedResult: data,
instanceId: instance.id,
});
namespacedInstance.emit(
"searchResultUpdated",
updatedResult
{
updatedResult: data,
instanceId: instance.id,
}
);
},
instance.id
@@ -176,6 +184,9 @@ export default class SocketService extends Service {
await ADCPPSocket.get(
`search/${instance.id}`
);
console.log(
JSON.stringify(currentInstance, null, 4)
);
// Send the instance to the client
await namespacedInstance.emit(
"searchesSent",
@@ -183,6 +194,7 @@ export default class SocketService extends Service {
searchInfo,
}
);
if (currentInstance.result_count === 0) {
console.log("No more search results.");
namespacedInstance.emit(
@@ -190,6 +202,7 @@ export default class SocketService extends Service {
{
message:
"No more search results.",
currentInstance,
}
);
}
@@ -214,7 +227,7 @@ export default class SocketService extends Service {
{ error }
);
} finally {
// await ADCPPSocket.disconnect();
await ADCPPSocket.disconnect();
}
},
},