Skip to content

Commit

Permalink
Prevent Test Area photos from showing on the front page #835 (#938)
Browse files Browse the repository at this point in the history
* updated nvmrc to Node 18
* excluded media objects with Test Area ID from front page. Made Test ID a configurable delimited list stored in .env
* feat: use regex to account for child areas
  • Loading branch information
hawkishpolicy authored Jul 28, 2023
1 parent 6ac3ed6 commit a0a8c79
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ PREBUILD_PROFILES=

# Google cloud storage bucket name
GC_BUCKET_NAME=openbeta-staging

# A comma-separated-list of test area IDs
# to exclude from the feed
NEXT_PUBLIC_TEST_AREA_IDS=18c5dd5c-8186-50b6-8a60-ae2948c548d1
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
12 changes: 11 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,18 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {

const recentTagsByUsers = await getMediaForFeed(20, 3)

const recentTags = recentTagsByUsers.flatMap(entry => entry.mediaWithTags)
const testAreaIds = Array.from(new Set((process.env.NEXT_PUBLIC_TEST_AREA_IDS ?? '').split(',')))

const mediaWithTags = recentTagsByUsers.flatMap(entry => entry.mediaWithTags)

const recentTags = mediaWithTags.filter(tag => {
return tag.entityTags.some(entityTag => {
return testAreaIds.every(testId => {
const regex = new RegExp(testId, 'g')
return !regex.test(entityTag.ancestors)
})
})
})
return {
props: {
exploreData: rs.data,
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3549,15 +3549,10 @@ camelcase@^6.2.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==

caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426:
version "1.0.30001430"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001430.tgz#638a8ae00b5a8a97e66ff43733b2701f81b101fa"
integrity sha512-IB1BXTZKPDVPM7cnV4iaKaHxckvdr/3xtctB3f7Hmenx3qYBhGtTZ//7EllK66aKXW98Lx0+7Yr0kxBtIt3tzg==

caniuse-lite@^1.0.30001406:
version "1.0.30001449"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001449.tgz#a8d11f6a814c75c9ce9d851dc53eb1d1dfbcd657"
integrity sha512-CPB+UL9XMT/Av+pJxCKGhdx+yg1hzplvFJQlJ2n68PyQGMz9L/E2zCyLdOL8uasbouTUgnPl+y0tccI/se+BEw==
caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001406, caniuse-lite@^1.0.30001426:
version "1.0.30001517"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001517.tgz"
integrity sha512-Vdhm5S11DaFVLlyiKu4hiUTkpZu+y1KA/rZZqVQfOD5YdDT/eQKlkt7NaE0WGOFgX32diqt9MiP9CAiFeRklaA==

chalk@^2.0.0:
version "2.4.2"
Expand Down

1 comment on commit a0a8c79

@vercel
Copy link

@vercel vercel bot commented on a0a8c79 Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.