Skip to content

Commit

Permalink
fix(recommend): rename maxRecommendations to limit (#6196)
Browse files Browse the repository at this point in the history
This is consistent with other widgets that don't have pagination like refinementList
  • Loading branch information
Haroenv committed May 16, 2024
1 parent 6ccffdf commit b6037c0
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('connectFrequentlyBoughtTogether', () => {
const makeWidget = connectFrequentlyBoughtTogether(render);
const widget = makeWidget({
objectIDs: ['1', '2'],
maxRecommendations: 10,
limit: 10,
threshold: 95,
queryParameters: { userToken: 'token' },
escapeHTML: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type FrequentlyBoughtTogetherConnectorParams<
/**
* The maximum number of recommendations to return.
*/
maxRecommendations?: number;
limit?: number;

/**
* Parameters to pass to the request.
Expand Down Expand Up @@ -90,7 +90,7 @@ const connectFrequentlyBoughtTogether: FrequentlyBoughtTogetherConnector =
FrequentlyBoughtTogetherConnectorParams['transformItems']
>,
objectIDs,
maxRecommendations,
limit,
threshold,
queryParameters,
} = widgetParams || {};
Expand Down Expand Up @@ -156,7 +156,7 @@ const connectFrequentlyBoughtTogether: FrequentlyBoughtTogetherConnector =
acc.addFrequentlyBoughtTogether({
objectID,
threshold,
maxRecommendations,
maxRecommendations: limit,
queryParameters: {
...queryParameters,
...(escapeHTML ? TAG_PLACEHOLDER : {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type LookingSimilarConnectorParams<THit extends BaseHit = BaseHit> = {
/**
* The number of recommendations to retrieve.
*/
maxRecommendations?: number;
limit?: number;
/**
* The threshold for the recommendations confidence score (between 0 and 100).
*/
Expand Down Expand Up @@ -82,7 +82,7 @@ const connectLookingSimilar: LookingSimilarConnector =
// @MAJOR: this can default to false
escapeHTML = true,
objectIDs,
maxRecommendations,
limit,
threshold,
fallbackParameters,
queryParameters,
Expand Down Expand Up @@ -152,7 +152,7 @@ const connectLookingSimilar: LookingSimilarConnector =
(acc, objectID) =>
acc.addLookingSimilar({
objectID,
maxRecommendations,
maxRecommendations: limit,
threshold,
fallbackParameters: {
...fallbackParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type RelatedProductsConnectorParams<THit extends BaseHit = BaseHit> = {
/**
* The number of recommendations to retrieve.
*/
maxRecommendations?: number;
limit?: number;
/**
* The threshold for the recommendations confidence score (between 0 and 100).
*/
Expand Down Expand Up @@ -83,7 +83,7 @@ const connectRelatedProducts: RelatedProductsConnector =
// @MAJOR: this can default to false
escapeHTML = true,
objectIDs,
maxRecommendations,
limit,
threshold,
fallbackParameters,
queryParameters,
Expand Down Expand Up @@ -153,7 +153,7 @@ const connectRelatedProducts: RelatedProductsConnector =
(acc, objectID) =>
acc.addRelatedProducts({
objectID,
maxRecommendations,
maxRecommendations: limit,
threshold,
fallbackParameters: {
...fallbackParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type TrendingItemsConnectorParams<THit extends BaseHit = BaseHit> = (
/**
* The number of recommendations to retrieve.
*/
maxRecommendations?: number;
limit?: number;
/**
* The threshold for the recommendations confidence score (between 0 and 100).
*/
Expand Down Expand Up @@ -89,7 +89,7 @@ const connectTrendingItems: TrendingItemsConnector =
const {
facetName,
facetValue,
maxRecommendations,
limit,
threshold,
fallbackParameters,
queryParameters,
Expand Down Expand Up @@ -156,7 +156,7 @@ const connectTrendingItems: TrendingItemsConnector =
return state.removeParams(this.$$id!).addTrendingItems({
facetName,
facetValue,
maxRecommendations,
maxRecommendations: limit,
threshold,
fallbackParameters: {
...fallbackParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ describe('frequentlyBoughtTogether', () => {

search
.removeWidgets([widget])
.addWidgets([
frequentlyBoughtTogether({ ...options, maxRecommendations: 0 }),
]);
.addWidgets([frequentlyBoughtTogether({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -156,9 +154,7 @@ describe('frequentlyBoughtTogether', () => {

search
.removeWidgets([widget])
.addWidgets([
frequentlyBoughtTogether({ ...options, maxRecommendations: 0 }),
]);
.addWidgets([frequentlyBoughtTogether({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -243,7 +239,7 @@ describe('frequentlyBoughtTogether', () => {
search.removeWidgets([widget]).addWidgets([
frequentlyBoughtTogether({
...options,
maxRecommendations: 0,
limit: 0,
}),
]);

Expand Down Expand Up @@ -334,7 +330,7 @@ describe('frequentlyBoughtTogether', () => {
search.removeWidgets([widget]).addWidgets([
frequentlyBoughtTogether({
...options,
maxRecommendations: 0,
limit: 0,
}),
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const frequentlyBoughtTogether: FrequentlyBoughtTogetherWidget =
const {
container,
objectIDs,
maxRecommendations,
limit,
queryParameters,
threshold,
escapeHTML,
Expand Down Expand Up @@ -203,7 +203,7 @@ const frequentlyBoughtTogether: FrequentlyBoughtTogetherWidget =
return {
...makeWidget({
objectIDs,
maxRecommendations,
limit,
queryParameters,
threshold,
escapeHTML,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('lookingSimilar', () => {

search
.removeWidgets([widget])
.addWidgets([lookingSimilar({ ...options, maxRecommendations: 0 })]);
.addWidgets([lookingSimilar({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -155,7 +155,7 @@ describe('lookingSimilar', () => {

search
.removeWidgets([widget])
.addWidgets([lookingSimilar({ ...options, maxRecommendations: 0 })]);
.addWidgets([lookingSimilar({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -240,7 +240,7 @@ describe('lookingSimilar', () => {
search.removeWidgets([widget]).addWidgets([
lookingSimilar({
...options,
maxRecommendations: 0,
limit: 0,
}),
]);

Expand Down Expand Up @@ -331,7 +331,7 @@ describe('lookingSimilar', () => {
search.removeWidgets([widget]).addWidgets([
lookingSimilar({
...options,
maxRecommendations: 0,
limit: 0,
}),
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const lookingSimilar: LookingSimilarWidget = function lookingSimilar(
const {
container,
objectIDs,
maxRecommendations,
limit,
queryParameters,
fallbackParameters,
threshold,
Expand Down Expand Up @@ -200,7 +200,7 @@ const lookingSimilar: LookingSimilarWidget = function lookingSimilar(
return {
...makeWidget({
objectIDs,
maxRecommendations,
limit,
queryParameters,
fallbackParameters,
threshold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ describe('relatedProducts', () => {

search.removeWidgets([relatedProductsWidget]);

search.addWidgets([
relatedProducts({ ...options, maxRecommendations: 0 }),
]);
search.addWidgets([relatedProducts({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -158,9 +156,7 @@ describe('relatedProducts', () => {

search.removeWidgets([relatedProductsWidget]);

search.addWidgets([
relatedProducts({ ...options, maxRecommendations: 0 }),
]);
search.addWidgets([relatedProducts({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -245,9 +241,7 @@ describe('relatedProducts', () => {

search.removeWidgets([relatedProductsWidget]);

search.addWidgets([
relatedProducts({ ...options, maxRecommendations: 0 }),
]);
search.addWidgets([relatedProducts({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -336,9 +330,7 @@ describe('relatedProducts', () => {

search.removeWidgets([relatedProductsWidget]);

search.addWidgets([
relatedProducts({ ...options, maxRecommendations: 0 }),
]);
search.addWidgets([relatedProducts({ ...options, limit: 0 })]);

await wait(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const relatedProducts: RelatedProductsWidget = function relatedProducts(
const {
container,
objectIDs,
maxRecommendations,
limit,
queryParameters,
fallbackParameters,
threshold,
Expand Down Expand Up @@ -212,7 +212,7 @@ const relatedProducts: RelatedProductsWidget = function relatedProducts(
return {
...makeWidget({
objectIDs,
maxRecommendations,
limit,
queryParameters,
fallbackParameters,
threshold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('trendingItems', () => {

search.removeWidgets([trendingItemsWidget]);

search.addWidgets([trendingItems({ ...options, maxRecommendations: 0 })]);
search.addWidgets([trendingItems({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -152,7 +152,7 @@ describe('trendingItems', () => {

search.removeWidgets([trendingItemsWidget]);

search.addWidgets([trendingItems({ ...options, maxRecommendations: 0 })]);
search.addWidgets([trendingItems({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -236,7 +236,7 @@ describe('trendingItems', () => {

search.removeWidgets([trendingItemsWidget]);

search.addWidgets([trendingItems({ ...options, maxRecommendations: 0 })]);
search.addWidgets([trendingItems({ ...options, limit: 0 })]);

await wait(0);

Expand Down Expand Up @@ -324,7 +324,7 @@ describe('trendingItems', () => {

search.removeWidgets([trendingItemsWidget]);

search.addWidgets([trendingItems({ ...options, maxRecommendations: 0 })]);
search.addWidgets([trendingItems({ ...options, limit: 0 })]);

await wait(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const trendingItems: TrendingItemsWidget = function trendingItems(
container,
facetName,
facetValue,
maxRecommendations,
limit,
queryParameters,
fallbackParameters,
threshold,
Expand Down Expand Up @@ -214,7 +214,7 @@ const trendingItems: TrendingItemsWidget = function trendingItems(
return {
...makeWidget({
...facetParameters,
maxRecommendations,
limit,
queryParameters,
fallbackParameters,
threshold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const FrequentlyBoughtTogetherUiComponent =

export function FrequentlyBoughtTogether<THit extends BaseHit = BaseHit>({
objectIDs,
maxRecommendations,
limit,
threshold,
queryParameters,
escapeHTML,
Expand All @@ -54,7 +54,7 @@ export function FrequentlyBoughtTogether<THit extends BaseHit = BaseHit>({
const { items } = useFrequentlyBoughtTogether<THit>(
{
objectIDs,
maxRecommendations,
limit,
threshold,
queryParameters,
escapeHTML,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-instantsearch/src/widgets/LookingSimilar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const LookingSimilarUiComponent = createLookingSimilarComponent({

export function LookingSimilar<THit extends BaseHit = BaseHit>({
objectIDs,
maxRecommendations,
limit,
threshold,
queryParameters,
fallbackParameters,
Expand All @@ -51,7 +51,7 @@ export function LookingSimilar<THit extends BaseHit = BaseHit>({
const { items } = useLookingSimilar<THit>(
{
objectIDs,
maxRecommendations,
limit,
threshold,
queryParameters,
fallbackParameters,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-instantsearch/src/widgets/RelatedProducts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const RelatedProductsUiComponent = createRelatedProductsComponent({

export function RelatedProducts<TItem extends BaseHit = BaseHit>({
objectIDs,
maxRecommendations,
limit,
threshold,
fallbackParameters,
queryParameters,
Expand All @@ -51,7 +51,7 @@ export function RelatedProducts<TItem extends BaseHit = BaseHit>({
const { items } = useRelatedProducts(
{
objectIDs,
maxRecommendations,
limit,
threshold,
fallbackParameters,
queryParameters,
Expand Down

0 comments on commit b6037c0

Please sign in to comment.