🔎 Wiring up the refactored elasticsearch endpoint

This commit is contained in:
2022-02-06 23:12:39 -08:00
parent c6265599de
commit cf1fe451c9
11 changed files with 143 additions and 85 deletions

View File

@@ -43,7 +43,7 @@
"ellipsize": "^0.1.0", "ellipsize": "^0.1.0",
"express": "^4.17.1", "express": "^4.17.1",
"fastest-validator": "^1.11.0", "fastest-validator": "^1.11.0",
"filename-parser": "^1.0.0", "filename-parser": "^1.0.1",
"final-form": "^4.20.2", "final-form": "^4.20.2",
"final-form-arrays": "^3.0.2", "final-form-arrays": "^3.0.2",
"html-to-text": "^8.1.0", "html-to-text": "^8.1.0",
@@ -74,7 +74,7 @@
"sharp": "^0.28.1", "sharp": "^0.28.1",
"socket.io-client": "^4.3.2", "socket.io-client": "^4.3.2",
"styled-components": "^5.3.3", "styled-components": "^5.3.3",
"threetwo-ui-typings": "^1.0.12", "threetwo-ui-typings": "^1.0.13",
"voca": "^1.4.0", "voca": "^1.4.0",
"websocket": "^1.0.34", "websocket": "^1.0.34",
"ws": "^7.5.3", "ws": "^7.5.3",

View File

@@ -14,9 +14,11 @@ import {
CV_ISSUES_METADATA_CALL_IN_PROGRESS, CV_ISSUES_METADATA_CALL_IN_PROGRESS,
CV_CLEANUP, CV_CLEANUP,
IMS_COMIC_BOOKS_DB_OBJECTS_FETCHED, IMS_COMIC_BOOKS_DB_OBJECTS_FETCHED,
CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED,
CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS,
} from "../constants/action-types"; } from "../constants/action-types";
import { import {
COMICBOOKINFO_SERVICE_URI, COMICVINE_SERVICE_URI,
LIBRARY_SERVICE_BASE_URI, LIBRARY_SERVICE_BASE_URI,
} from "../constants/endpoints"; } from "../constants/endpoints";
@@ -32,7 +34,7 @@ export const comicinfoAPICall = (options) => async (dispatch) => {
type: CV_API_CALL_IN_PROGRESS, type: CV_API_CALL_IN_PROGRESS,
inProgress: true, inProgress: true,
}); });
const serviceURI = `${COMICBOOKINFO_SERVICE_URI}/${options.callURIAction}`; const serviceURI = `${COMICVINE_SERVICE_URI}/${options.callURIAction}`;
const response = await http(serviceURI, { const response = await http(serviceURI, {
method: options.callMethod, method: options.callMethod,
params: options.callParams, params: options.callParams,
@@ -65,23 +67,54 @@ export const comicinfoAPICall = (options) => async (dispatch) => {
}); });
} }
}; };
export const findIssuesForSeriesInLibrary = export const getIssuesForSeries = (comicObjectID: any) => async (dispatch) => {
(comicObjectID: any) => async (dispatch) => { dispatch({
dispatch({ type: CV_ISSUES_METADATA_CALL_IN_PROGRESS,
type: CV_ISSUES_METADATA_CALL_IN_PROGRESS, });
}); dispatch({
dispatch({ type: CV_CLEANUP,
type: CV_CLEANUP, });
});
await axios({ const issues = await axios({
url: `${LIBRARY_SERVICE_BASE_URI}/findIssuesForSeriesInLibrary`, url: `${COMICVINE_SERVICE_URI}/getIssuesForSeries`,
method: "POST", method: "POST",
params: { params: {
comicObjectID, comicObjectID,
}, },
}); });
};
dispatch({
type: CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS,
issues: issues.data,
});
};
export const analyzeLibrary = (issues) => async (dispatch) => {
dispatch({
type: CV_ISSUES_METADATA_CALL_IN_PROGRESS,
});
const queryObjects = issues.map((issue) => {
const { id, name, issue_number } = issue;
return {
issueId: id,
issueName: name,
volumeName: issue.volume.name,
issueNumber: issue_number,
};
});
const foo = await axios({
url: `${LIBRARY_SERVICE_BASE_URI}/findIssueForSeries`,
method: "POST",
data: {
queryObjects,
},
});
console.log(foo);
dispatch({
type: CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED,
matches: foo.data,
});
};
export const getComicBookDetailById = export const getComicBookDetailById =
(comicBookObjectId: string) => async (dispatch) => { (comicBookObjectId: string) => async (dispatch) => {

View File

@@ -1,7 +1,7 @@
import axios from "axios"; import axios from "axios";
import { IFolderData } from "threetwo-ui-typings"; import { IFolderData } from "threetwo-ui-typings";
import { import {
COMICBOOKINFO_SERVICE_URI, COMICVINE_SERVICE_URI,
LIBRARY_SERVICE_BASE_URI, LIBRARY_SERVICE_BASE_URI,
} from "../constants/endpoints"; } from "../constants/endpoints";
import { import {
@@ -161,19 +161,19 @@ export const fetchComicVineMatches =
console.log(seriesSearchQuery); console.log(seriesSearchQuery);
axios axios
.request({ .request({
url: `${COMICBOOKINFO_SERVICE_URI}/volumeBasedSearch`, url: `${COMICVINE_SERVICE_URI}/volumeBasedSearch`,
method: "POST", method: "POST",
data: { data: {
format: "json", format: "json",
// hack // hack
query: issueSearchQuery.searchParams.searchTerms.name query: issueSearchQuery.inferredIssueDetails.name
.replace(/[^a-zA-Z0-9 ]/g, "") .replace(/[^a-zA-Z0-9 ]/g, "")
.trim(), .trim(),
limit: "100", limit: "100",
page: 1, page: 1,
resources: "volume", resources: "volume",
scorerConfiguration: { scorerConfiguration: {
searchParams: issueSearchQuery.searchParams, searchParams: issueSearchQuery.inferredIssueDetails,
}, },
rawFileDetails: searchPayload.rawFileDetails, rawFileDetails: searchPayload.rawFileDetails,
}, },

View File

@@ -23,10 +23,7 @@ export const ComicVineMatchPanel = (comicVineData): ReactElement => {
<div className="tags has-addons"> <div className="tags has-addons">
<span className="tag">Title</span> <span className="tag">Title</span>
<span className="tag is-info"> <span className="tag is-info">
{ {comicVineSearchQueryObject.issue.inferredIssueDetails.name}
comicVineSearchQueryObject.issue.searchParams.searchTerms
.name
}
</span> </span>
</div> </div>
</div> </div>
@@ -35,7 +32,7 @@ export const ComicVineMatchPanel = (comicVineData): ReactElement => {
<span className="tag">Number</span> <span className="tag">Number</span>
<span className="tag is-info"> <span className="tag is-info">
{ {
comicVineSearchQueryObject.issue.searchParams.searchTerms comicVineSearchQueryObject.issue.inferredIssueDetails
.number .number
} }
</span> </span>

View File

@@ -32,15 +32,7 @@ export const Dashboard = (): ReactElement => {
{!isEmpty(recentComics) && !isEmpty(recentComics.docs) ? ( {!isEmpty(recentComics) && !isEmpty(recentComics.docs) ? (
<> <>
<div className="columns">
<div className="column is-half card">
<div className="card-content">
<h1 className="is-size-5">13,476 Books</h1>
</div>
</div>
</div>
<RecentlyImported comicBookCovers={recentComics} /> <RecentlyImported comicBookCovers={recentComics} />
{!isNil(volumeGroups) ? <VolumeGroups /> : null} {!isNil(volumeGroups) ? <VolumeGroups /> : null}
</> </>
) : ( ) : (

View File

@@ -24,7 +24,7 @@ export const RecentlyImported = ({
return ( return (
<> <>
<div className="content"> <div className="content">
<h4 className="subtitle">Recently Imported</h4> <h4 className="title is-4">Recently Imported</h4>
</div> </div>
<Masonry <Masonry
breakpointCols={breakpointColumnsObj} breakpointCols={breakpointColumnsObj}

View File

@@ -4,7 +4,8 @@ import { useDispatch, useSelector } from "react-redux";
import { useParams } from "react-router"; import { useParams } from "react-router";
import { import {
getComicBookDetailById, getComicBookDetailById,
findIssuesForSeriesInLibrary, getIssuesForSeries,
analyzeLibrary,
} from "../../actions/comicinfo.actions"; } from "../../actions/comicinfo.actions";
import PotentialLibraryMatches from "./PotentialLibraryMatches"; import PotentialLibraryMatches from "./PotentialLibraryMatches";
import Masonry from "react-masonry-css"; import Masonry from "react-masonry-css";
@@ -31,7 +32,7 @@ const VolumeDetails = (props): ReactElement => {
potentialMatchesInLibrary: { potentialMatchesInLibrary: {
content: () => { content: () => {
const ids = map(matches, partialRight(pick, "_id")); const ids = map(matches, partialRight(pick, "_id"));
const matchIds = ids.map((id:any) => id._id); const matchIds = ids.map((id: any) => id._id);
return <PotentialLibraryMatches matches={matchIds} />; return <PotentialLibraryMatches matches={matchIds} />;
}, },
}, },
@@ -44,6 +45,10 @@ const VolumeDetails = (props): ReactElement => {
setVisible(true); setVisible(true);
}, []); }, []);
const analyzeIssues = useCallback((issues) => {
dispatch(analyzeLibrary(issues));
}, []);
const comicBookDetails = useSelector( const comicBookDetails = useSelector(
(state: RootState) => state.comicInfo.comicBookDetail, (state: RootState) => state.comicInfo.comicBookDetail,
); );
@@ -53,45 +58,56 @@ const VolumeDetails = (props): ReactElement => {
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
dispatch(findIssuesForSeriesInLibrary(comicObjectId)); dispatch(getIssuesForSeries(comicObjectId));
dispatch(getComicBookDetailById(comicObjectId)); dispatch(getComicBookDetailById(comicObjectId));
}, []); }, []);
const { comicObjectId } = useParams<{ comicObjectId: string }>(); const { comicObjectId } = useParams<{ comicObjectId: string }>();
const IssuesInVolume = () => ( const IssuesInVolume = () => (
<Masonry <>
breakpointCols={breakpointColumnsObj} {!isUndefined(issuesForVolume) ? (
className="issues-container" <div className="button" onClick={() => analyzeIssues(issuesForVolume)}>
columnClassName="issues-column" Analyze Library
> </div>
{!isUndefined(issuesForVolume) && !isEmpty(issuesForVolume) ) : null}
? issuesForVolume.map((issue) => { <Masonry
return ( breakpointCols={breakpointColumnsObj}
<Card className="issues-container"
key={issue.issue.id} columnClassName="issues-column"
imageUrl={issue.issue.image.thumb_url} >
orientation={"vertical"} {!isUndefined(issuesForVolume) && !isEmpty(issuesForVolume)
hasDetails={!isEmpty(issue.matches) ? true : false} ? issuesForVolume.map((issue) => {
borderColorClass={!isEmpty(issue.matches) ? "green-border" : ""} return (
backgroundColor={!isEmpty(issue.matches) ? "#e0f5d0" : ""} <Card
onClick={() => openPotentialLibraryMatchesPanel(issue.matches)} key={issue.id}
> imageUrl={issue.image.thumb_url}
{!isEmpty(issue.matches) ? ( orientation={"vertical"}
<> hasDetails={!isEmpty(issue.matches) ? true : false}
<span className="icon has-text-success"> borderColorClass={
<i className="fa-regular fa-clone"></i> !isEmpty(issue.matches) ? "green-border" : ""
</span> }
<span className="tag is-light is-warning is-size-7"> backgroundColor={!isEmpty(issue.matches) ? "#e0f5d0" : ""}
{"#" + issue.issue.issue_number} onClick={() =>
</span> openPotentialLibraryMatchesPanel(issue.matches)
</> }
) : null} >
</Card> {!isEmpty(issue.matches) ? (
); <>
}) <span className="icon has-text-success">
: "loading"} <i className="fa-regular fa-clone"></i>
</Masonry> </span>
<span className="tag is-light is-warning is-size-7">
{"#" + issue.issue_number}
</span>
</>
) : null}
</Card>
);
})
: "loading"}
</Masonry>
</>
); );
// Tab content and header details // Tab content and header details

View File

@@ -28,7 +28,8 @@ export const IMS_DATA_FETCH_ERROR = "IMS_DATA_FETCH_ERROR";
// Single or multiple comic book mongo objects // Single or multiple comic book mongo objects
export const IMS_COMIC_BOOK_DB_OBJECT_FETCHED = export const IMS_COMIC_BOOK_DB_OBJECT_FETCHED =
"IMS_COMIC_BOOK_DB_OBJECT_FETCHED"; "IMS_COMIC_BOOK_DB_OBJECT_FETCHED";
export const IMS_COMIC_BOOKS_DB_OBJECTS_FETCHED = "IMS_COMIC_BOOKS_DB_OBJECTS_FETCHED"; export const IMS_COMIC_BOOKS_DB_OBJECTS_FETCHED =
"IMS_COMIC_BOOKS_DB_OBJECTS_FETCHED";
export const IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS = export const IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS =
"IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS"; "IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS";
export const IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED = export const IMS_COMIC_BOOK_DB_OBJECT_CALL_FAILED =
@@ -50,6 +51,9 @@ export const CV_ISSUES_METADATA_FETCH_FAILED =
"CV_ISSUES_METADATA_FETCH_FAILED"; "CV_ISSUES_METADATA_FETCH_FAILED";
export const CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS = export const CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS =
"CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS"; "CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS";
export const CV_ISSUES_FOR_VOLUME_IN_LIBRARY_UPDATED =
"CV_ISSUES_FOR_VOLUME_IN_LIBRARY_UPDATED";
export const CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED = "CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED";
// extracted comic archive // extracted comic archive
export const IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS = export const IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS =

View File

@@ -16,7 +16,7 @@ export const CORS_PROXY_SERVER_URI = hostURIBuilder({
apiPath: "/", apiPath: "/",
}); });
export const COMICBOOKINFO_SERVICE_URI = hostURIBuilder({ export const COMICVINE_SERVICE_URI = hostURIBuilder({
protocol: "http", protocol: "http",
host: process.env.UNDERLYING_HOSTNAME || "localhost", host: process.env.UNDERLYING_HOSTNAME || "localhost",
port: "3080", port: "3080",

View File

@@ -1,3 +1,4 @@
import { isEmpty, extend, each } from "lodash";
import { import {
CV_API_CALL_IN_PROGRESS, CV_API_CALL_IN_PROGRESS,
CV_SEARCH_SUCCESS, CV_SEARCH_SUCCESS,
@@ -7,8 +8,11 @@ import {
IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS, IMS_COMIC_BOOK_DB_OBJECT_CALL_IN_PROGRESS,
CV_ISSUES_METADATA_CALL_IN_PROGRESS, CV_ISSUES_METADATA_CALL_IN_PROGRESS,
CV_ISSUES_METADATA_FETCH_SUCCESS, CV_ISSUES_METADATA_FETCH_SUCCESS,
CV_ISSUES_FOR_VOLUME_IN_LIBRARY_UPDATED,
CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED,
CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS, CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS,
} from "../constants/action-types"; } from "../constants/action-types";
import { refineQuery } from "filename-parser";
const initialState = { const initialState = {
searchResults: [], searchResults: [],
@@ -67,12 +71,24 @@ function comicinfoReducer(state = initialState, action) {
}; };
case CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS: case CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS:
console.log("jagan", action); // console.log("jagan", action);
return { return {
...state, ...state,
issuesForVolume: [...state.issuesForVolume, action.result], issuesForVolume: action.issues,
inProgress: false, inProgress: false,
}; };
case CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED:
console.log(action);
const updatedState = [...state.issuesForVolume];
// updatedState[issueToUpdateIndex].matches = action.result.matches;
// console.log(issueToUpdateIndex);
// console.log(updatedState[issueToUpdateIndex]);
return {
...state,
issuesForVolume: updatedState,
};
default: default:
return state; return state;
} }

View File

@@ -5805,10 +5805,10 @@ filehound@^1.17.5:
moment "^2.29.1" moment "^2.29.1"
unit-compare "^1.0.1" unit-compare "^1.0.1"
filename-parser@^1.0.0: filename-parser@^1.0.1:
version "1.0.0" version "1.0.1"
resolved "https://registry.yarnpkg.com/filename-parser/-/filename-parser-1.0.0.tgz#bad742add537ec075136cee49129e0146ed34596" resolved "https://registry.yarnpkg.com/filename-parser/-/filename-parser-1.0.1.tgz#cd54d9131913dd2bf96c2a1d19edf7c1ee75c4cc"
integrity sha512-3j7TgfElImSXhYcBzCP75+mC08IdRGmIBOm6XcJciI3xnQU6A4imzzUEJ2Ps717s5ycBkzQgUtjArGWGh/Gmkg== integrity sha512-MMzuklXc1r4N6uQXg8CQYxoiTX7w6QPeJE73L5lCTSoNR7CftCXHIA6tyINomkvWIUanrlqTB629DyTIqCucEA==
dependencies: dependencies:
compromise "^13.11.4" compromise "^13.11.4"
compromise-dates "^2.2.1" compromise-dates "^2.2.1"
@@ -12857,10 +12857,10 @@ text-table@^0.2.0, text-table@~0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
threetwo-ui-typings@^1.0.12: threetwo-ui-typings@^1.0.13:
version "1.0.12" version "1.0.13"
resolved "https://registry.yarnpkg.com/threetwo-ui-typings/-/threetwo-ui-typings-1.0.12.tgz#9f05542d7fa67b2349e20b0555ab196521fa8448" resolved "https://registry.yarnpkg.com/threetwo-ui-typings/-/threetwo-ui-typings-1.0.13.tgz#9437a8c08a6984ebd1dcdf308e06e404dee11c81"
integrity sha512-lKADNpD2Oa3Wmf6tdZhaPSNfIFa0KtstsZLE0yalTjqKmtQZM7Ct2OnlCkH7aonDuVn+jgcRMwkcP9krCqa2fw== integrity sha512-AQiY8/hbp+TobBoehNTEoNco97AoiKYQjAANSFDR3pSD5jFn5qjLlKntvqdNF9Fg5tcS0ReYe0AjsvKshKpixQ==
dependencies: dependencies:
typescript "^4.3.2" typescript "^4.3.2"