Skip to content

Commit

Permalink
Single index (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Breen <[email protected]>
  • Loading branch information
cultpodcasts and cultpodcasts authored Mar 28, 2024
1 parent a02e2e5 commit b1da770
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,38 @@ export default {
.then(async (data: any) => {
let dataPoint: AnalyticsEngineDataPoint = { indexes: [], blobs: [] };
let requestBody = JSON.stringify(data);
let index: string = "";
if (data.search) {
dataPoint.indexes!.push(data.search);
index = data.search;
dataPoint.blobs!.push(data.search);
dataPoint.blobs!.push("search");
}
if (data.filter) {
let filter: string = data.filter;
if (filter.indexOf("(podcastName eq '") == 0) {
let query = filter.slice(17, -2);
dataPoint.indexes!.push(query);
if (index) {
index += " podcast=" + query;
} else {
index = "podcast=" + query;
}
dataPoint.blobs!.push(query);
dataPoint.blobs!.push("podcast");
} else if (filter.indexOf("subjects/any(s: s eq '") == 0) {
let query = filter.slice(22, - 2);
dataPoint.indexes!.push(query);
if (index) {
index += " subject=" + query;
} else {
index = "subject=" + query;
}
dataPoint.blobs!.push(query);
dataPoint.blobs!.push("subject");
} else {
console.log("Unrecognised search filter");
}
}
dataPoint.indexes!.push(index);

if (!data.search && !data.filter)
{
console.log("Unrecognised search request");
Expand Down

0 comments on commit b1da770

Please sign in to comment.