🔧 WIP kafka-powered search + download
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -331,19 +331,46 @@ 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;
|
||||
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
|
||||
);
|
||||
|
||||
return {
|
||||
wantedComics: result.docs,
|
||||
total: result.totalDocs,
|
||||
page: result.page,
|
||||
limit: result.limit,
|
||||
pages: result.totalPages,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error finding comics:", error);
|
||||
throw error;
|
||||
|
||||
@@ -124,12 +124,9 @@ export default class SocketService extends Service {
|
||||
config: "object",
|
||||
},
|
||||
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 +143,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 +158,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
|
||||
|
||||
Reference in New Issue
Block a user