+
-
+
{allowTrade && (
)}
diff --git a/web/pages/add-funds.tsx b/web/pages/add-funds.tsx
index 2ecf6317..339be265 100644
--- a/web/pages/add-funds.tsx
+++ b/web/pages/add-funds.tsx
@@ -19,10 +19,10 @@ export default function AddFundsPage() {
-
+
bets.length)
+ const dailyContractCounts = dailyContracts.map(
+ (contracts) => contracts.length
+ )
+ const dailyCommentCounts = dailyComments.map((comments) => comments.length)
+
+ const dailyActiveUsers = _.zip(dailyContracts, dailyBets, dailyComments).map(
+ ([contracts, bets, comments]) => {
+ const creatorIds = (contracts ?? []).map((c) => c.creatorId)
+ const betUserIds = (bets ?? []).map((bet) => bet.userId)
+ const commentUserIds = (comments ?? []).map((comment) => comment.userId)
+ return _.uniq([...creatorIds, ...betUserIds, commentUserIds]).length
+ }
+ )
+
+ return {
+ props: {
+ startDate: startDate.valueOf(),
+ dailyActiveUsers,
+ dailyBetCounts,
+ dailyContractCounts,
+ dailyCommentCounts,
+ },
+ revalidate: 12 * 60 * 60, // regenerate after half a day
+ }
+}
+
+export default function Analytics(props: {
+ startDate: number
+ dailyActiveUsers: number[]
+ dailyBetCounts: number[]
+ dailyContractCounts: number[]
+ dailyCommentCounts: number[]
+}) {
return (
-
+
+
+
)
}
+
+function CustomAnalytics(props: {
+ startDate: number
+ dailyActiveUsers: number[]
+ dailyBetCounts: number[]
+ dailyContractCounts: number[]
+ dailyCommentCounts: number[]
+}) {
+ const {
+ startDate,
+ dailyActiveUsers,
+ dailyBetCounts,
+ dailyContractCounts,
+ dailyCommentCounts,
+ } = props
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function FirebaseAnalytics() {
+ // Edit dashboard at https://datastudio.google.com/u/0/reporting/faeaf3a4-c8da-4275-b157-98dad017d305/page/Gg3/edit
+ return (
+
+ )
+}
diff --git a/web/pages/create.tsx b/web/pages/create.tsx
index 76afa8d2..5e8830e0 100644
--- a/web/pages/create.tsx
+++ b/web/pages/create.tsx
@@ -137,7 +137,7 @@ export function NewContract(props: { question: string; tag?: string }) {
Answer type
-
diff --git a/web/pages/fold/[...slugs]/index.tsx b/web/pages/fold/[...slugs]/index.tsx
index 1d77444b..757fe325 100644
--- a/web/pages/fold/[...slugs]/index.tsx
+++ b/web/pages/fold/[...slugs]/index.tsx
@@ -12,7 +12,10 @@ import {
getFoldBySlug,
getFoldContracts,
} from '../../../lib/firebase/folds'
-import { ActivityFeed, findActiveContracts } from '../../activity'
+import {
+ ActivityFeed,
+ findActiveContracts,
+} from '../../../components/activity-feed'
import { TagsList } from '../../../components/tags-list'
import { Row } from '../../../components/layout/row'
import { UserLink } from '../../../components/user-page'
@@ -36,6 +39,9 @@ import { SEO } from '../../../components/SEO'
import { useTaggedContracts } from '../../../hooks/use-contracts'
import { Linkify } from '../../../components/linkify'
import { filterDefined } from '../../../../common/util/array'
+import { useRecentBets } from '../../../hooks/use-bets'
+import { useRecentComments } from '../../../hooks/use-comments'
+import { LoadingIndicator } from '../../../components/loading-indicator'
export async function getStaticProps(props: { params: { slugs: string[] } }) {
const { slugs } = props.params
@@ -48,7 +54,6 @@ export async function getStaticProps(props: { params: { slugs: string[] } }) {
const bets = await Promise.all(
contracts.map((contract) => listAllBets(contract.id))
)
- const betsByContract = _.fromPairs(contracts.map((c, i) => [c.id, bets[i]]))
let activeContracts = findActiveContracts(contracts, [], _.flatten(bets))
const [resolved, unresolved] = _.partition(
@@ -57,10 +62,6 @@ export async function getStaticProps(props: { params: { slugs: string[] } }) {
)
activeContracts = [...unresolved, ...resolved]
- const activeContractBets = activeContracts.map(
- (contract) => betsByContract[contract.id] ?? []
- )
-
const creatorScores = scoreCreators(contracts, bets)
const traderScores = scoreTraders(contracts, bets)
const [topCreators, topTraders] = await Promise.all([
@@ -76,8 +77,6 @@ export async function getStaticProps(props: { params: { slugs: string[] } }) {
curator,
contracts,
activeContracts,
- activeContractBets,
- activeContractComments: activeContracts.map(() => []),
traderScores,
topTraders,
creatorScores,
@@ -117,15 +116,8 @@ export default function FoldPage(props: {
creatorScores: { [userId: string]: number }
topCreators: User[]
}) {
- const {
- curator,
- activeContractBets,
- activeContractComments,
- traderScores,
- topTraders,
- creatorScores,
- topCreators,
- } = props
+ const { curator, traderScores, topTraders, creatorScores, topCreators } =
+ props
const router = useRouter()
const { slugs } = router.query as { slugs: string[] }
@@ -151,6 +143,9 @@ export default function FoldPage(props: {
props.activeContracts.map((contract) => contractsMap[contract.id])
)
+ const recentBets = useRecentBets()
+ const recentComments = useRecentComments()
+
if (fold === null || !foldSubpages.includes(page) || slugs[2]) {
return
}
@@ -233,19 +228,24 @@ export default function FoldPage(props: {
/>
)}
{page === 'activity' ? (
- <>
-
- {activeContracts.length === 0 && (
-
- No activity from matching markets.{' '}
- {isCurator && 'Try editing to add more tags!'}
-
- )}
- >
+ recentBets && recentComments ? (
+ <>
+
+ {activeContracts.length === 0 && (
+
+ No activity from matching markets.{' '}
+ {isCurator && 'Try editing to add more tags!'}
+
+ )}
+ >
+ ) : (
+
+ )
) : (
{
- const { folds, recentComments } = props
+ const { folds } = props
const user = useUser()
const contracts = useActiveContracts() ?? props.contracts
@@ -51,13 +50,15 @@ const Home = (props: {
contracts
)
- const recentBets = useGetRecentBets()
- const { activeContracts, activeBets, activeComments } =
- useFindActiveContracts({
- contracts: yourContracts,
- recentBets: recentBets ?? [],
- recentComments,
- })
+ const initialRecentBets = useGetRecentBets()
+ const recentBets = useRecentBets() ?? initialRecentBets
+ const recentComments = useRecentComments() ?? props.recentComments
+
+ const { activeContracts } = useFindActiveContracts({
+ contracts: yourContracts,
+ recentBets: initialRecentBets ?? [],
+ recentComments: props.recentComments,
+ })
const exploreContracts = useExploreContracts()
@@ -71,7 +72,7 @@ const Home = (props: {
return (
-
+
@@ -85,7 +86,7 @@ const Home = (props: {
-
+
) : (
diff --git a/web/pages/make-predictions.tsx b/web/pages/make-predictions.tsx
index c3d42d6d..36d210ef 100644
--- a/web/pages/make-predictions.tsx
+++ b/web/pages/make-predictions.tsx
@@ -248,7 +248,7 @@ ${TEST_VALUE}
error={anteError}
setError={setAnteError}
disabled={isSubmitting}
- contractId={undefined}
+ contractIdForLoan={undefined}
/>