Skip to content

Commit

Permalink
Merge pull request #215 from eshedmargalit/em/restore-search
Browse files Browse the repository at this point in the history
Em/restore search
  • Loading branch information
eshedmargalit authored Sep 9, 2023
2 parents 4b96d37 + a5cdd19 commit 8666022
Show file tree
Hide file tree
Showing 19 changed files with 8,060 additions and 6,670 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
18
12 changes: 10 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"katex": "^0.12.0",
"lodash": "^4.17.20",
"moment": "^2.29.4",
"node-sass": "^7.0.0",
"postcss": "^8.4.29",
"postcss-safe-parser": "^6.0.0",
"prettier": "^2.2.1",
"prettierrc": "^0.0.0-5",
"react": "^16.9.0",
Expand Down Expand Up @@ -62,6 +63,7 @@
"lint": "eslint 'src/**/*.{ts,tsx}' --fix"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@testing-library/dom": "^7.29.0",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.2",
Expand Down Expand Up @@ -89,7 +91,13 @@
"msw": "^0.24.2",
"prettier": "^2.2.1",
"pretty-quick": "^1.11.1",
"ts-jest": "^27.0.5"
"sass": "^1.65.1",
"ts-jest": "^27.0.5",
"ts-node": "^10.9.1"
},
"resolutions": {
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2"
},
"husky": {
"hooks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const paperSearch = async (input: string): Promise<Paper[]> => {
const { data } = await axios.get<PaperResponse[]>(`/api/search/${input}`);
return data.map(constructPaperFromResponse);
} catch (err) {
console.error(err);
return [];
}
};
Expand Down
16 changes: 9 additions & 7 deletions client/src/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ export const hashString = (str: string): number => {
return Math.abs(hash);
};

export const makeHandleModalCopy = (userId: string) => (review: Review): void => {
const link = `${window.location.origin}/profiles/${userId}/${review._id}`;
navigator.clipboard.writeText(link);
notification.success({
message: 'Link Copied!',
});
};
export const makeHandleModalCopy =
(userId: string) =>
(review: Review): void => {
const link = `${window.location.origin}/profiles/${userId}/${review._id}`;
navigator.clipboard.writeText(link);
notification.success({
message: 'Link Copied!',
});
};
3 changes: 1 addition & 2 deletions client/src/demoContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ export const demoReviews: Review[] = [
other: [
"It would have been nice to see if the other SOTA models perform better on the two-category task -- I was expecting to see results there and didn't. Did I just miss something?",
],
tldr:
"Natural image datasets aren't useful for separating models of object recognition, since a trivial V1 model can reach SOTA on Caltech101 but fail on a two-category task with more within-category variability",
tldr: "Natural image datasets aren't useful for separating models of object recognition, since a trivial V1 model can reach SOTA on Caltech101 but fail on a two-category task with more within-category variability",
keywords: ['v1', 'object recognition', 'natural images', 'caltech101'],
},
createdAt: new Date(moment().subtract(2.9, 'weeks').format()),
Expand Down
2 changes: 1 addition & 1 deletion client/src/theming/themes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFromLocalStorage, saveToLocalStorage } from '../storage';

export const themes = ['orange', 'blue', 'pink', 'green'] as const;
export type ThemeColor = typeof themes[number];
export type ThemeColor = (typeof themes)[number];

export function getPersistedTheme(): ThemeColor | null {
const persisted = getFromLocalStorage('theme');
Expand Down
8,887 changes: 4,684 additions & 4,203 deletions client/yarn.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@types/cookie-session": "^2.0.41",
"@types/express": "^4.17.9",
"@types/lodash": "^4.14.165",
"@types/mongoose": "^5.10.1",
"@types/passport": "^1.0.4",
"@types/mongoose": "5.10.1",
"@types/passport": "1.0.4",
"@types/passport-google-oauth20": "^2.0.4",
"antd": "4.0.0",
"axios": "^0.21.2",
Expand All @@ -28,12 +28,12 @@
"express": "^4.17.3",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"mongoose": "^5.13.20",
"mongoose": "5.13.20",
"node-sass": "^7.0.0",
"nodemon": "^1.19.2",
"passport": "^0.4.1",
"passport-google-oauth20": "^2.0.0",
"ts-node": "^9.0.0"
"ts-node": "^10.9.1"
},
"devDependencies": {
"@types/classnames": "^2.3.1",
Expand Down
5 changes: 3 additions & 2 deletions server/src/apis/openalex/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ export function authorFromAuthorResponse(resp: AuthorsResponse): Author | null {
}

export function paperFromWork(work: Work): IPaper {
const journal = work.primary_location.source?.display_name;
return {
title: work.display_name,
authors: authorshipsToAuthors(work.authorships),
institutions: authorshipsToInstitutions(work.authorships),
date: moment(work.publication_date, 'YYYY-MM-DD').toDate(),
journal: work.host_venue.display_name,
journal: journal || '',
doi: work.doi,
url: work.host_venue.url,
url: work.primary_location.landing_page_url || '',
};
}
1 change: 1 addition & 0 deletions server/src/apis/openalex/openalex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export async function getPapersByTitle(title: string): Promise<IPaper[]> {

export async function getPapersByDOI(doi: string): Promise<IPaper[]> {
const workResponse = await openAlexGet<Work>(`works/doi/${doi}`);

if (!workResponse) {
return [];
}
Expand Down
8 changes: 5 additions & 3 deletions server/src/apis/openalex/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
interface Venue {
display_name: string;
url: string;
source: {
display_name?: string;
};
landing_page_url?: string;
}

interface Author {
Expand All @@ -20,7 +22,7 @@ export interface Authorship {
export interface Work {
display_name: string;
publication_date: string;
host_venue: Venue;
primary_location: Venue;
authorships: Authorship[];
doi: string;
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/draftRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = (app: Application) => {
{ googleId: req.user.googleId },
{
$pull: {
drafts: { _id: new Types.ObjectId(req.params.id) },
drafts: { _id: Types.ObjectId(req.params.id) },
},
},
{ new: true },
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/paperRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = (app: Application) => {
{ googleId: req.user.googleId },
{
$pull: {
reviews: { _id: new Types.ObjectId(req.params.id) },
reviews: { _id: Types.ObjectId(req.params.id) },
},
},
{ new: true },
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/reviewRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = (app: Application) => {
{ googleId: req.user.googleId },
{
$pull: {
reviews: { _id: new Types.ObjectId(req.params.id) },
reviews: { _id: Types.ObjectId(req.params.id) },
},
},
{ new: true },
Expand Down
1 change: 1 addition & 0 deletions server/src/services/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function searchByAuthor(query: string): Promise<IPaper[]> {

export default async function search(query: string): Promise<IPaper[]> {
const papers = await Promise.all([searchByTitle(query), searchByDOI(query), searchByAuthor(query)]);
console.log(papers);

return _uniqBy(_flatten(papers), 'title');
}
Loading

0 comments on commit 8666022

Please sign in to comment.