Skip to content

Commit

Permalink
Remove unused code (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel authored Dec 10, 2024
1 parent 6ef7620 commit 044134a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 58 deletions.
44 changes: 2 additions & 42 deletions components/country/CountryDetails.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios'
import Flag from 'components/Flag'
import { StyledStickySubMenu } from 'components/SharedStyledComponents'
import ThirdPartyDataChart from 'components/ThirdPartyDataChart'
Expand All @@ -10,7 +9,7 @@ import Overview from 'components/country/Overview'
import PageNavMenu from 'components/country/PageNavMenu'
import WebsitesSection from 'components/country/Websites'
import { useRouter } from 'next/router'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useEffect, useMemo, useState } from 'react'
import { useIntl } from 'react-intl'
import dayjs from 'services/dayjs'
import useScrollPosition from '/hooks/useScrollPosition'
Expand All @@ -37,15 +36,9 @@ const Header = ({ countryCode, countryName }) => {
)
}

const CountryDetails = ({
countryCode,
overviewStats,
reports,
coverageDataSSR,
}) => {
const CountryDetails = ({ countryCode, overviewStats, reports }) => {
const intl = useIntl()
const countryName = getLocalisedRegionName(countryCode, intl.locale)
const [newData, setNewData] = useState(false)
const router = useRouter()
const { query } = router

Expand Down Expand Up @@ -77,29 +70,6 @@ const CountryDetails = ({
}
}, [])

const fetchTestCoverageData = useCallback(
(testGroupList) => {
const fetcher = async (testGroupList) => {
const client = axios.create({
baseURL: process.env.NEXT_PUBLIC_OONI_API,
}) // eslint-disable-line
const result = await client.get('/api/_/test_coverage', {
params: {
probe_cc: countryCode,
test_groups: testGroupList,
},
})
// TODO: Use React.createContext to pass along data and methods
setNewData({
networkCoverage: result.data.network_coverage,
testCoverage: result.data.test_coverage,
})
}
fetcher(testGroupList)
},
[countryCode, setNewData],
)

// Sync page URL params with changes from form values
const onSubmit = ({ since, until }) => {
const params = {
Expand All @@ -117,9 +87,6 @@ const CountryDetails = ({
}
}

const { testCoverage, networkCoverage } =
newData !== false ? newData : coverageDataSSR

return (
<>
<CountryHead
Expand All @@ -141,16 +108,9 @@ const CountryDetails = ({
>
<Overview
countryName={countryName}
middleboxCount={overviewStats.middlebox_detected_networks}
imCount={overviewStats.im_apps_blocked}
circumventionTools={overviewStats.circumvention_tools_blocked}
blockedWebsitesCount={overviewStats.websites_confirmed_blocked}
networkCount={overviewStats.network_count}
measurementCount={overviewStats.measurement_count}
measuredSince={overviewStats.first_bucket_date}
testCoverage={testCoverage}
networkCoverage={networkCoverage}
fetchTestCoverageData={fetchTestCoverageData}
featuredArticles={reports}
/>
<Form onSubmit={onSubmit} since={since} until={until} />
Expand Down
20 changes: 4 additions & 16 deletions pages/country/[countryCode].js
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,17 @@ export async function getServerSideProps({ res, query }) {
try {
const client = axios.create({ baseURL: process.env.NEXT_PUBLIC_OONI_API }) // eslint-disable-line
const results = await Promise.all([
// XXX cc @darkk we should ideally have better dedicated daily dumps for this view
client.get('/api/_/test_coverage', { params: { probe_cc: countryCode } }),
client.get('/api/_/country_overview', {
params: { probe_cc: countryCode },
}),
client.get('https://ooni.org/pageindex.json'),
])
const testCoverage = results[0].data.test_coverage
const networkCoverage = results[0].data.network_coverage
const overviewStats = results[1].data
const reports = getCountryReports(countryCode, results[2].data)

const overviewStats = results[0].data
const reports = getCountryReports(countryCode, results[1].data)

return {
props: {
testCoverage,
networkCoverage,
overviewStats,
reports,
countryCode,
Expand All @@ -65,13 +60,7 @@ export async function getServerSideProps({ res, query }) {
}
}

const Country = ({
countryCode,
overviewStats,
reports,
error,
...coverageDataSSR
}) => {
const Country = ({ countryCode, overviewStats, reports, error }) => {
return (
<>
{error ? (
Expand All @@ -81,7 +70,6 @@ const Country = ({
countryCode={countryCode}
overviewStats={overviewStats}
reports={reports}
coverageDataSSR={coverageDataSSR}
/>
)}
</>
Expand Down

0 comments on commit 044134a

Please sign in to comment.