Skip to content

Commit

Permalink
Better logs
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Jun 2, 2024
1 parent 31a0263 commit f971f28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions api/src/libs/indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ class Indexer {
}
}
async processSubscription(chatId, subscription, item) {
console.log(chatId, item, `newUpdate`);
console.log("New update triggered, fetching item data", item.id);
console.log("New update triggered, fetching item data", chatId, item.id);
const subscriptionResp = await redis.hGet(`subscriptions`, chatId);
if (!subscriptionResp) {
return;
Expand All @@ -273,7 +272,7 @@ class Indexer {
responseType: "text",
},
);
console.log("Update evaluation response", resp.data);
console.log(`Update evaluation response for ${chatId}`, resp.data);
if (resp.data && !resp.data.includes("NOT_RELEVANT")) {
await redis.publish(`newUpdate:${chatId}`, resp.data);
}
Expand Down
4 changes: 1 addition & 3 deletions api/src/packages/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,12 @@ app.delete(
// Validators
app.use(errorMiddleware);

//app.get("/discovery/stream", );

app.ws("/discovery/:chatId/updates", discoveryController.updates);

const start = async () => {
console.log("Starting API ...", port);
await redis.connect();
await pubSubClient.connect()
await pubSubClient.connect();

await setIndexedModelParams(app);

Expand Down
7 changes: 5 additions & 2 deletions api/src/packages/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ async function start() {
const streamId = parsedData.commitId.baseID.toString();
const op = parsedData.eventType === 0 ? "c" : "u";

console.log("New event: ", modelId, streamId, op);

try {
switch (modelId) {
case runtimeDefinition.models.IndexItem.id:
switch (op) {
case "c":
console.log(`IndexItem ${streamId} created`);
await indexer.createIndexItemEvent(streamId);
break;
case "u":
console.log(`IndexItem ${streamId} updated`);
await indexer.updateIndexItemEvent(streamId);
break;
}
Expand All @@ -63,16 +63,19 @@ async function start() {
// We'll index objects only if they belong to an index.
break;
case "u":
console.log(`WebPage ${streamId} updated`);
await indexer.updateWebPageEvent(streamId);
break;
}
break;
case runtimeDefinition.models.Embedding.id:
switch (op) {
case "c":
console.log(`Embedding ${streamId} created`);
await indexer.createEmbeddingEvent(streamId);
break;
case "u":
console.log(`Embedding ${streamId} updated`);
await indexer.updateEmbeddingEvent(streamId);
break;
}
Expand Down

0 comments on commit f971f28

Please sign in to comment.