Skip to content

Commit

Permalink
Fetch real search categories from labs #3342
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Jun 20, 2024
1 parent 9c03a16 commit 5a076ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,7 @@ import { Logger } from '../../logger';
import * as DE from '../../types/data-error';
import { decodeAndLogFailures } from '../decode-and-log-failures';
import { ExternalQueries } from '../external-queries';

const hardCodedResponse = {
data: [
{
type: 'category',
id: 'Infectious Diseases (except HIV/AIDS)',
},
{
type: 'category',
id: 'Epidemiology',
},
],
};
import { QueryExternalService } from '../query-external-service';

const scietyLabsCategoriesResponseCodec = t.type({
data: t.array(t.type({
Expand All @@ -30,9 +18,12 @@ const scietyLabsCategoriesResponseCodec = t.type({

const url = 'https://labs.sciety.org/api/papers/v1/preprints/classifications?filter%5Bevaluated_only%5D=true';

export const fetchSearchCategories = (logger: Logger): ExternalQueries['fetchSearchCategories'] => () => pipe(
hardCodedResponse,
TE.right,
export const fetchSearchCategories = (
queryExternalService: QueryExternalService,
logger: Logger,
): ExternalQueries['fetchSearchCategories'] => () => pipe(
url,
queryExternalService(),
TE.chainEitherKW(flow(
decodeAndLogFailures(logger, scietyLabsCategoriesResponseCodec, { url }),
E.mapLeft(() => DE.unavailable),
Expand Down
2 changes: 1 addition & 1 deletion src/third-parties/instantiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const instantiate = (
logger,
),
fetchRecommendedPapers: createFetchRecommendedPapers(queryExternalService, logger),
fetchSearchCategories: fetchSearchCategories(logger),
fetchSearchCategories: fetchSearchCategories(queryExternalService, logger),
fetchStaticFile: fetchStaticFile(logger),
fetchUserAvatarUrl: fetchUserAvatarUrl(queryExternalService, logger),
getArticleSubjectArea: getBiorxivOrMedrxivCategory({ queryExternalService, logger }),
Expand Down

0 comments on commit 5a076ee

Please sign in to comment.