Route recommendation search to recsys + add user_id
(#353)
* Route recommendation search to recsys 5% of the time + add `user_id` ## Ticket 334 send some recommended requests to recsys ## Approach `doSearch`: - If the search options include `related_to`, route that to the new `searchRecommendations` which performs the 5% check + appends `user_id` at the end. This way, we don't need to alter the function signature of `doSearch`. - Else, run proceed as normal. * Always go to alt provider f Co-authored-by: Thomas Zarebczan <thomas.zarebczan@gmail.com>
This commit is contained in:
parent
2adbbc2899
commit
fd17ab4c8b
6 changed files with 29 additions and 6 deletions
|
@ -14,6 +14,7 @@ LBRY_WEB_BUFFER_API=https://collector-service.api.lbry.tv/api/v1/events/video
|
|||
COMMENT_SERVER_API=https://comments.odysee.com/api/v2
|
||||
COMMENT_SERVER_NAME=Odysee
|
||||
SEARCH_SERVER_API=https://lighthouse.odysee.com/search
|
||||
SEARCH_SERVER_API_ALT=https://recsys.odysee.com/search
|
||||
SOCKETY_SERVER_API=wss://sockety.odysee.com/ws
|
||||
THUMBNAIL_CDN_URL=https://thumbnails.odysee.com/optimize/
|
||||
THUMBNAIL_CARDS_CDN_URL=https://cards.odysee.com/
|
||||
|
|
|
@ -13,6 +13,7 @@ const config = {
|
|||
LBRY_WEB_STREAMING_API: process.env.LBRY_WEB_STREAMING_API, //cdn.lbryplayer.xyz',
|
||||
LBRY_WEB_BUFFER_API: process.env.LBRY_WEB_BUFFER_API,
|
||||
SEARCH_SERVER_API: process.env.SEARCH_SERVER_API,
|
||||
SEARCH_SERVER_API_ALT: process.env.SEARCH_SERVER_API_ALT,
|
||||
COMMENT_SERVER_API: process.env.COMMENT_SERVER_API,
|
||||
COMMENT_SERVER_NAME: process.env.COMMENT_SERVER_NAME,
|
||||
SOCKETY_SERVER_API: process.env.SOCKETY_SERVER_API,
|
||||
|
|
|
@ -4,6 +4,7 @@ import React, { useEffect, useRef, useState, useLayoutEffect } from 'react';
|
|||
import { lazyImport } from 'util/lazyImport';
|
||||
import classnames from 'classnames';
|
||||
import analytics from 'analytics';
|
||||
import { setSearchUserId } from 'redux/actions/search';
|
||||
import { buildURI, parseURI } from 'util/lbryURI';
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
import Router from 'component/router/index';
|
||||
|
@ -214,6 +215,7 @@ function App(props: Props) {
|
|||
useEffect(() => {
|
||||
if (userId) {
|
||||
analytics.setUser(userId);
|
||||
setSearchUserId(userId);
|
||||
}
|
||||
}, [userId]);
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ export default function YoutubeTransferStatus(props: Props) {
|
|||
!hasPendingTransfers &&
|
||||
!isYoutubeTransferComplete &&
|
||||
!isNotElligible &&
|
||||
__('Please check back later. This may take up to 1 week.')}
|
||||
__('Please check back later, this may take a few hours.')}
|
||||
|
||||
{isYoutubeTransferComplete && !isNotElligible && __('View your channel or choose a new channel to sync.')}
|
||||
{isNotElligible && (
|
||||
|
|
|
@ -9,7 +9,8 @@ import { makeSelectSearchUrisForQuery, selectSearchValue } from 'redux/selectors
|
|||
import handleFetchResponse from 'util/handle-fetch';
|
||||
import { getSearchQueryString } from 'util/query-params';
|
||||
import { getRecommendationSearchOptions } from 'util/search';
|
||||
import { SEARCH_SERVER_API } from 'config';
|
||||
import { SEARCH_SERVER_API, SEARCH_SERVER_API_ALT } from 'config';
|
||||
import { SEARCH_OPTIONS } from 'constants/search';
|
||||
|
||||
type Dispatch = (action: any) => any;
|
||||
type GetState = () => { claims: any, search: SearchState };
|
||||
|
@ -24,13 +25,27 @@ type SearchOptions = {
|
|||
|
||||
let lighthouse = {
|
||||
CONNECTION_STRING: SEARCH_SERVER_API,
|
||||
user_id: '',
|
||||
|
||||
search: (queryString: string) => fetch(`${lighthouse.CONNECTION_STRING}?${queryString}`).then(handleFetchResponse),
|
||||
|
||||
searchRecommendations: (queryString: string) => {
|
||||
if (lighthouse.user_id) {
|
||||
return fetch(`${SEARCH_SERVER_API_ALT}?${queryString}${lighthouse.user_id}`).then(handleFetchResponse);
|
||||
} else {
|
||||
return fetch(`${SEARCH_SERVER_API_ALT}?${queryString}`).then(handleFetchResponse);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const setSearchApi = (endpoint: string) => {
|
||||
lighthouse.CONNECTION_STRING = endpoint.replace(/\/*$/, '/'); // exactly one slash at the end;
|
||||
};
|
||||
|
||||
export const setSearchUserId = (userId: ?string) => {
|
||||
lighthouse.user_id = userId ? `&user_id=${userId}` : '';
|
||||
};
|
||||
|
||||
export const doSearch = (rawQuery: string, searchOptions: SearchOptions) => (
|
||||
dispatch: Dispatch,
|
||||
getState: GetState
|
||||
|
@ -63,8 +78,11 @@ export const doSearch = (rawQuery: string, searchOptions: SearchOptions) => (
|
|||
type: ACTIONS.SEARCH_START,
|
||||
});
|
||||
|
||||
lighthouse
|
||||
.search(queryWithOptions)
|
||||
const cmd = searchOptions.hasOwnProperty(SEARCH_OPTIONS.RELATED_TO)
|
||||
? lighthouse.searchRecommendations
|
||||
: lighthouse.search;
|
||||
|
||||
cmd(queryWithOptions)
|
||||
.then((data: { body: Array<{ name: string, claimId: string }>, poweredBy: string }) => {
|
||||
const { body: result, poweredBy } = data;
|
||||
const uris = [];
|
||||
|
|
|
@ -5,7 +5,8 @@ import { SIMPLE_SITE } from 'config';
|
|||
export default function Footer() {
|
||||
useEffect(() => {
|
||||
if (!window.sp) {
|
||||
document.getElementById('gdprPrivacyFooter').style.display = 'none';
|
||||
const privacyFooterButton = document.getElementById('gdprPrivacyFooter');
|
||||
if (privacyFooterButton) privacyFooterButton.style.display = 'none';
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
Loading…
Reference in a new issue