diff --git a/src/Apps/InfiniteDiscovery/InfiniteDiscoveryApp.tsx b/src/Apps/InfiniteDiscovery/InfiniteDiscoveryApp.tsx index ff7a7a0a0f6..be2d9026ef1 100644 --- a/src/Apps/InfiniteDiscovery/InfiniteDiscoveryApp.tsx +++ b/src/Apps/InfiniteDiscovery/InfiniteDiscoveryApp.tsx @@ -1,14 +1,24 @@ -import { Flex, Button, Text, Separator } from "@artsy/palette" +import { + Flex, + Button, + Text, + Separator, + Input, + Expandable, + Label, +} from "@artsy/palette" import React, { useEffect } from "react" import { sampleSize } from "lodash" import { getMetaphysicsEndpoint } from "System/Relay/getMetaphysicsEndpoint" -const buildMetaphysicsQuery = (likedArtworks, dismissedArtworks) => { +const buildMetaphysicsQuery = (likedArtworks, dismissedArtworks, weight) => { const likedArtworkIds = likedArtworks.map(artwork => artwork.id) const dismissedArtworkIds = dismissedArtworks.map(artwork => artwork.id) // Adjust query variables based on conditions const variables = { + osWeights: weight, + useOpenSearch: true, likedArtworkIds: likedArtworkIds.length > 2 ? likedArtworkIds : [], dismissedArtworkIds: likedArtworkIds.length < 3 @@ -18,9 +28,10 @@ const buildMetaphysicsQuery = (likedArtworks, dismissedArtworks) => { return { query: ` - query InfiniteDiscoveryAppQuery($likedArtworkIds: [String], $dismissedArtworkIds: [String]) { + query InfiniteDiscoveryAppQuery($likedArtworkIds: [String], $dismissedArtworkIds: [String], $osWeights: [Float], $useOpenSearch: Boolean) { discoverArtworks( - useOpenSearch: true, + useOpenSearch: $useOpenSearch, + osWeights: $osWeights, likedArtworkIds: $likedArtworkIds, excludeArtworkIds: $dismissedArtworkIds ) { @@ -29,6 +40,7 @@ const buildMetaphysicsQuery = (likedArtworks, dismissedArtworks) => { id: internalID title artistNames + medium image { url } @@ -70,6 +82,8 @@ export const InfiniteDiscoveryApp = () => { const [likedArtworks, setLikedArtworks] = React.useState([]) as any const [dismissedArtworks, setDismissedArtworks] = React.useState([]) as any const [loading, setLoading] = React.useState(false) + const [mltWeight, setMltWeight] = React.useState(0.6) + const [knnWeight, setKnnWeight] = React.useState(0.4) const onLike = artwork => { setLikedArtworks([...likedArtworks, artwork]) @@ -82,7 +96,7 @@ export const InfiniteDiscoveryApp = () => { const initialArtworks = async () => { const response = await request(getMetaphysicsEndpoint(), { body: JSON.stringify( - buildMetaphysicsQuery(likedArtworks, dismissedArtworks) + buildMetaphysicsQuery(likedArtworks, dismissedArtworks, [0.6, 0.4]) ), }) @@ -103,7 +117,10 @@ export const InfiniteDiscoveryApp = () => { const response = await request(getMetaphysicsEndpoint(), { body: JSON.stringify( - buildMetaphysicsQuery(likedArtworks, dismissedArtworks) + buildMetaphysicsQuery(likedArtworks, dismissedArtworks, [ + mltWeight, + knnWeight, + ]) ), }) @@ -133,7 +150,7 @@ export const InfiniteDiscoveryApp = () => { preferences.
- + + + + + setMltWeight(parseFloat(e.target.value))} + max={1} + min={0} + /> + + setKnnWeight(parseFloat(e.target.value))} + max={1} + min={0} + /> + +


@@ -233,6 +278,7 @@ const Artwork = ({ onLike, onDismiss, viewed = false, artworkResource }) => {

{artwork?.artistNames}

+

{artwork.medium}

{artwork.id}

{viewed || (artwork.title !== "Artwork not available" && (