Skip to content

Commit

Permalink
accomodate episode-id in logging (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Breen <[email protected]>
  • Loading branch information
cultpodcasts and cultpodcasts committed May 26, 2024
1 parent 98b91f6 commit 3bb911b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"devDependencies": {
"@cloudflare/workers-types": "^4.20240423.0",
"typescript": "^5.0.4",
"wrangler": "^3.56.0"
"wrangler": "^3.57.1"
},
"dependencies": {
"@cfworker/jwt": "^4.0.6",
Expand Down
16 changes: 13 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,14 @@ app.post("/search", async (c) => {
if (data.filter) {
let filter: string = data.filter;
if (filter.indexOf("(podcastName eq '") == 0) {
let query = filter.slice(17, -2);
const idFilter = "') and (id eq ";
let filterCutoff = -2;
if (filter.indexOf(idFilter) >= 0) {
filterCutoff = filterCutoff = filter.indexOf(idFilter);
const episodeId = filter.slice(filterCutoff + idFilter.length, -2);
dataPoint.blobs!.push(episodeId);
}
let query = filter.slice(17, filterCutoff);
if (index) {
index += " podcast=" + query;
} else {
Expand Down Expand Up @@ -190,7 +197,11 @@ app.post("/search", async (c) => {
});
if (dataPoint) {
dataPoint.blobs?.push(response.status.toString());
c.env.Analytics.writeDataPoint(dataPoint);
try {
c.env.Analytics.writeDataPoint(dataPoint);
} catch (error) {
console.log(error);
}
}

c.header("Cache-Control", "max-age=600");
Expand Down Expand Up @@ -380,7 +391,6 @@ app.get("/podcasts", auth0Middleware, async (c) => {
return c.json({ error: "Unauthorised" }, 403);
});


app.get("/discovery-curation", auth0Middleware, async (c) => {
const auth0Payload: Auth0JwtPayload = c.var.auth0('payload');
c.header("Cache-Control", "max-age=600");
Expand Down

0 comments on commit 3bb911b

Please sign in to comment.