Skip to content

Commit

Permalink
Fix imdb_id NaN error (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leslie-Wong-H authored Apr 25, 2023
2 parents c6b3cfa + a96e2e6 commit ba6c55c
Show file tree
Hide file tree
Showing 3 changed files with 409 additions and 341 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
- 3306:3306

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Run liresolr
Expand Down Expand Up @@ -103,9 +103,9 @@ jobs:
--network $CONTAINER_NETWORK \
-p 19532:19532 \
ghcr.io/shotit/shotit-sorter:v0.9.1
# Sleep for 60 seconds to wait for Milvus Proxy and Searcher ready
- name: Sleep for 60 seconds
run: sleep 60s
# Sleep for 120 seconds to wait for Milvus Proxy and Searcher ready
- name: Sleep for 120 seconds
run: sleep 120s
shell: bash
- run: yarn install --frozen-lockfile
- run: yarn jest
Expand All @@ -131,7 +131,7 @@ jobs:
EMAIL_SMTP: smtp.ethereal.email
EMAIL_SMTP_PORT: 587
- name: Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
66 changes: 33 additions & 33 deletions src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default async (req, res) => {
// .reduce((list, { d, id }) => {
.reduce((list, { score: d, id }) => {
// merge nearby results within 5 seconds in the same filename
const imdb_id = Number(id.split("/")[0]);
const imdb_id = String(id.split("/")[0]);
const filename = id.split("/")[1];
const t = Number(id.split("/")[2]);
const index = list.findIndex(
Expand Down Expand Up @@ -453,38 +453,38 @@ export default async (req, res) => {
}
}

if ("imdbInfo" in req.query) {
const response = await fetch("https://graphql.anilist.co/", {
method: "POST",
body: JSON.stringify({
query: `query ($ids: [Int]) {
Page(page: 1, perPage: 50) {
media(id_in: $ids, type: ANIME) {
id
idMal
title {
native
romaji
english
}
synonyms
isAdult
}
}
}
`,
variables: { ids: result.map((e) => e.imdb) },
}),
headers: { "Content-Type": "application/json" },
});
if (response.status < 400) {
const imdbData = (await response.json()).data.Page.media;
result = result.map((entry) => {
entry.imdb = imdbData.find((e) => e.id === entry.imdb);
return entry;
});
}
}
// if ("imdbInfo" in req.query) {
// const response = await fetch("https://graphql.anilist.co/", {
// method: "POST",
// body: JSON.stringify({
// query: `query ($ids: [Int]) {
// Page(page: 1, perPage: 50) {
// media(id_in: $ids, type: ANIME) {
// id
// idMal
// title {
// native
// romaji
// english
// }
// synonyms
// isAdult
// }
// }
// }
// `,
// variables: { ids: result.map((e) => e.imdb) },
// }),
// headers: { "Content-Type": "application/json" },
// });
// if (response.status < 400) {
// const imdbData = (await response.json()).data.Page.media;
// result = result.map((entry) => {
// entry.imdb = imdbData.find((e) => e.id === entry.imdb);
// return entry;
// });
// }
// }

await logAndDequeue(knex, redis, uid, priority, 200, searchTime, result[0]?.similarity);
await redis.set(`s:${uid}`, `${searchCount + 1}`);
Expand Down
Loading

0 comments on commit ba6c55c

Please sign in to comment.