Skip to content

Commit

Permalink
🔥Remove lang filtering and adjust short filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Mar 13, 2024
1 parent 29b8274 commit 9caec65
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 38 deletions.
4 changes: 2 additions & 2 deletions packages/atlas/src/api/hooks/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
useGetMostViewedVideosConnectionQuery,
useGetVideosCountQuery,
} from '@/api/queries/__generated__/videos.generated'
import { publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'

export const useFullVideo = (
id: string,
Expand Down Expand Up @@ -48,7 +48,7 @@ export const useChannelPreviewVideos = (
const { data, ...rest } = useGetBasicVideosQuery({
...opts,
variables: {
where: { ...publicCryptoVideoFilter, channel: { id_eq: channelId } },
where: getPublicCryptoVideoFilter({ channel: { id_eq: channelId } }),
orderBy: VideoOrderByInput.CreatedAtDesc,
offset: 0,
limit: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CarouselProps } from '@/components/Carousel'
import { RankingNumberTile } from '@/components/RankingNumberTile'
import { Section } from '@/components/Section/Section'
import { VideoTileViewer } from '@/components/_video/VideoTileViewer'
import { publicChannelFilter, publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter, publicChannelFilter } from '@/config/contentFilter'
import { useMediaMatch } from '@/hooks/useMediaMatch'
import { breakpoints } from '@/styles'
import { createPlaceholderData } from '@/utils/data'
Expand Down Expand Up @@ -51,10 +51,7 @@ export const TopTenVideos: FC<TopTenVideosProps> = ({ period }) => {
orderBy: VideoOrderByInput.ViewsNumDesc,
limit: 10,
periodDays: period === 'week' ? 7 : 30,
where: {
...publicCryptoVideoFilter,
channel: publicChannelFilter,
},
where: getPublicCryptoVideoFilter({ channel: publicChannelFilter }),
},
{ onError: (error) => SentryLogger.error('Failed to fetch most viewed videos', 'TopTenVideos', error) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CSSTransition, SwitchTransition } from 'react-transition-group'
import { useBasicVideos } from '@/api/hooks/video'
import { VideoOrderByInput, VideoWhereInput } from '@/api/queries/__generated__/baseTypes.generated'
import { BasicVideoFieldsFragment } from '@/api/queries/__generated__/fragments.generated'
import { publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'
import { cVar, transitions } from '@/styles'
import { getRandomIntInclusive } from '@/utils/number'

Expand Down Expand Up @@ -41,13 +41,12 @@ export const VideoOverlay: FC<VideoOverlayProps> = ({
const commonFiltersFactory = (where?: VideoWhereInput) => ({
limit: 1,
orderBy: VideoOrderByInput.CreatedAtAsc,
where: {
...publicCryptoVideoFilter,
where: getPublicCryptoVideoFilter({
channel: {
id_eq: channelId,
},
...where,
},
}),
})
const { videos: newerVideos, loading: loadingNewestVideos } = useBasicVideos(
commonFiltersFactory({ createdAt_gt: currentVideoCreatedAt })
Expand Down
25 changes: 20 additions & 5 deletions packages/atlas/src/config/contentFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ export const cancelledVideoFilter: VideoWhereInput = {
},
}

const browserLanguage = navigator.language?.split('-')[0]
// const browserLanguage = navigator.language?.split('-')[0]

export const publicCryptoVideoFilter: VideoWhereInput = {
export const singlePublicCryptoVideoFilter: VideoWhereInput = {
isPublic_eq: true,
isCensored_eq: false,
isShort_not_eq: true,
isShortDerived_isNull: true,
orionLanguage_in: [...(browserLanguage ? [browserLanguage] : []), 'en'],
// orionLanguage_in: [...(browserLanguage ? [browserLanguage] : []), 'en'],
media: {
isAccepted_eq: true,
},
Expand All @@ -34,3 +32,20 @@ export const publicCryptoVideoFilter: VideoWhereInput = {
isPublic_eq: true,
},
}

export const getPublicCryptoVideoFilter = (extraWhere?: VideoWhereInput): VideoWhereInput => ({
OR: [
{
...singlePublicCryptoVideoFilter,
isShort_not_eq: true,
isShortDerived_isNull: true,
...(extraWhere ?? {}),
},
{
...singlePublicCryptoVideoFilter,
isShort_isNull: true,
isShortDerived_isNull: true,
...(extraWhere ?? {}),
},
],
})
7 changes: 3 additions & 4 deletions packages/atlas/src/hooks/useNftSectionFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCallback, useMemo, useState } from 'react'
import { OwnedNftOrderByInput, OwnedNftWhereInput } from '@/api/queries/__generated__/baseTypes.generated'
import { SvgActionSell, SvgActionSettings, SvgActionShoppingCart } from '@/assets/icons'
import { FilterButtonOption, SectionFilter } from '@/components/FilterButton'
import { publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'
import { tokenNumberToHapiBn } from '@/joystream-lib/utils'

export const NFT_STATUSES: FilterButtonOption[] = [
Expand Down Expand Up @@ -106,11 +106,10 @@ export const useNftSectionFilters = () => {
const commonFilters = {
lastSalePrice_gte: minPrice ? tokenNumberToHapiBn(minPrice).toString() : undefined,
lastSalePrice_lte: maxPrice ? tokenNumberToHapiBn(maxPrice).toString() : undefined,
video: {
...publicCryptoVideoFilter,
video: getPublicCryptoVideoFilter({
...(isMatureExcluded ? { isExcluded_eq: false } : {}),
...(isPromotionalExcluded ? { hasMarketing_eq: false } : {}),
},
}),
}
return {
OR: mappedStatus.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EmptyFallback } from '@/components/EmptyFallback'
import { Section } from '@/components/Section/Section'
import { Button } from '@/components/_buttons/Button'
import { VideoTileViewer } from '@/components/_video/VideoTileViewer'
import { publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'
import { absoluteRoutes } from '@/config/routes'
import { useInfiniteVideoGrid } from '@/hooks/useInfiniteVideoGrid'
import { DEFAULT_VIDEO_GRID } from '@/styles'
Expand All @@ -27,12 +27,11 @@ export const CategoryVideos: FC<CategoryVideosProps> = ({ categoriesId }) => {
const { tiles, pageInfo, fetchMore, columns } = useInfiniteVideoGrid<GetBasicVideosConnectionQuery>({
query: GetBasicVideosConnectionDocument,
variables: {
where: {
...publicCryptoVideoFilter,
where: getPublicCryptoVideoFilter({
category: {
id_in: categoriesId,
},
},
}),
orderBy: VideoOrderByInput.VideoRelevanceDesc,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GetBasicVideosConnectionLightweightDocument } from '@/api/queries/__gen
import { Section } from '@/components/Section/Section'
import { VideoContentTemplate } from '@/components/_templates/VideoContentTemplate'
import { VideoTileViewer } from '@/components/_video/VideoTileViewer'
import { publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'
import { useHeadTags } from '@/hooks/useHeadTags'
import { useInfiniteVideoGrid } from '@/hooks/useInfiniteVideoGrid'
import { DEFAULT_VIDEO_GRID, sizes } from '@/styles'
Expand All @@ -16,7 +16,7 @@ export const CuratorHomepage = () => {
const { columns, fetchMore, pageInfo, tiles } = useInfiniteVideoGrid({
query: GetBasicVideosConnectionLightweightDocument,
variables: {
where: publicCryptoVideoFilter,
where: getPublicCryptoVideoFilter(),
orderBy: VideoOrderByInput.VideoRelevanceDesc,
},
})
Expand Down
12 changes: 5 additions & 7 deletions packages/atlas/src/views/viewer/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Section } from '@/components/Section/Section'
import { ReferralsBanner } from '@/components/_referrals/ReferralsBanner/ReferralsBanner'
import { VideoContentTemplate } from '@/components/_templates/VideoContentTemplate'
import { VideoTileViewer } from '@/components/_video/VideoTileViewer'
import { publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'
import { useHeadTags } from '@/hooks/useHeadTags'
import { useInfiniteVideoGrid } from '@/hooks/useInfiniteVideoGrid'
import { useVideoGridRows } from '@/hooks/useVideoGridRows'
Expand Down Expand Up @@ -59,22 +59,20 @@ const useHomeVideos = () => {
const { data, loading } = useGetCuratedHompageVideosQuery({
notifyOnNetworkStatusChange: true,
variables: {
where: {
...publicCryptoVideoFilter,
where: getPublicCryptoVideoFilter({
orionLanguage_in: undefined,
includeInHomeFeed_eq: true,
},
}),
skipVideoIds: ['-1'],
},
})
const avoidIds = data?.dumbPublicFeedVideos ? data.dumbPublicFeedVideos?.map((video) => video.id) : undefined
const { columns, fetchMore, pageInfo, tiles } = useInfiniteVideoGrid({
query: GetBasicVideosConnectionLightweightDocument,
variables: {
where: {
...publicCryptoVideoFilter,
where: getPublicCryptoVideoFilter({
id_not_in: avoidIds,
},
}),
orderBy: VideoOrderByInput.VideoRelevanceDesc,
},
options: {
Expand Down
10 changes: 5 additions & 5 deletions packages/atlas/src/views/viewer/VideoView/MoreVideos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Button } from '@/components/_buttons/Button'
import { ChannelLink } from '@/components/_channel/ChannelLink'
import { VideoTileViewer } from '@/components/_video/VideoTileViewer'
import { displayCategoriesLookup } from '@/config/categories'
import { publicCryptoVideoFilter } from '@/config/contentFilter'
import { getPublicCryptoVideoFilter, singlePublicCryptoVideoFilter } from '@/config/contentFilter'
import { absoluteRoutes } from '@/config/routes'
import { useMediaMatch } from '@/hooks/useMediaMatch'
import { createPlaceholderData } from '@/utils/data'
Expand Down Expand Up @@ -37,13 +37,13 @@ export const MoreVideos: FC<MoreVideosProps> = ({
const videoCategories = categoryId ? displayCategoriesLookup[categoryId].videoCategories : undefined
const where =
type === 'channel'
? { ...publicCryptoVideoFilter, channel: { ...publicCryptoVideoFilter.channel, id_eq: channelId } }
: {
...publicCryptoVideoFilter,
? getPublicCryptoVideoFilter({ channel: { ...singlePublicCryptoVideoFilter.channel, id_eq: channelId } })
: getPublicCryptoVideoFilter({
category: {
id_in: videoCategories,
},
}
})

// we fetch +1 because we need to filter duplicated video
const { videos = [], loading } = useBasicVideos(
{
Expand Down

0 comments on commit 9caec65

Please sign in to comment.