Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove contract popularityScore related stuff #2510

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions backend/scripts/backfill-popularity-scores.ts

This file was deleted.

25 changes: 0 additions & 25 deletions backend/scripts/fix-popularity-scores.ts

This file was deleted.

8 changes: 1 addition & 7 deletions backend/shared/src/importance-score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function calculateImportanceScore(
const contractsWithUpdates: Contract[] = []

for (const contract of contracts) {
const { importanceScore, popularityScore, dailyScore, freshnessScore } =
const { importanceScore, dailyScore, freshnessScore } =
computeContractScores(
now,
contract,
Expand All @@ -94,12 +94,10 @@ export async function calculateImportanceScore(
// NOTE: These scores aren't updated in firestore, so are never accurate in the data blob
if (
contract.importanceScore !== importanceScore ||
contract.popularityScore !== popularityScore ||
contract.dailyScore !== dailyScore ||
contract.freshnessScore !== freshnessScore
) {
contract.importanceScore = importanceScore
contract.popularityScore = popularityScore
contract.dailyScore = dailyScore
contract.freshnessScore = freshnessScore
contractsWithUpdates.push(contract)
Expand Down Expand Up @@ -155,7 +153,6 @@ export async function calculateImportanceScore(
id: contract.id,
data: `${JSON.stringify(contract)}::jsonb`,
importance_score: contract.importanceScore,
popularity_score: contract.popularityScore,
freshness_score: contract.freshnessScore,
}))
)
Expand Down Expand Up @@ -227,8 +224,6 @@ export const computeContractScores = (
) => {
const todayScore = likesToday + tradersToday
const thisWeekScore = likesWeek + tradersWeek
const thisWeekScoreWeight = thisWeekScore / 10
const popularityScore = todayScore + thisWeekScoreWeight
const wasCreatedToday = contract.createdTime > now - DAY_MS

const { createdTime, closeTime, isResolved, outcomeType } = contract
Expand Down Expand Up @@ -342,7 +337,6 @@ export const computeContractScores = (
return {
todayScore,
thisWeekScore,
popularityScore: popularityScore >= 1 ? popularityScore : 0,
freshnessScore,
dailyScore,
importanceScore,
Expand Down
2 changes: 0 additions & 2 deletions backend/supabase/contracts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ create table if not exists
resolution_time timestamptz,
resolution_probability numeric,
resolution text,
popularity_score numeric,
importance_score numeric,
freshness_score numeric default 0,
data jsonb not null,
Expand Down Expand Up @@ -93,7 +92,6 @@ begin
end;
new.resolution_probability := ((new.data) ->> 'resolutionProbability')::numeric;
new.resolution := (new.data) ->> 'resolution';
new.popularity_score := coalesce(((new.data) ->> 'popularityScore')::numeric, 0);
new.deleted := coalesce(((new.data) ->> 'deleted')::boolean, false);
new.group_slugs := case
when new.data ? 'groupSlugs' then jsonb_array_to_text_array((new.data) -> 'groupSlugs')
Expand Down
3 changes: 0 additions & 3 deletions common/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ supabase status: columns exist for
resolutionTime?: timestamp (from millis)
resolution?: text
resolutionProbability?: numeric
popularityScore: numeric
importanceScore: numeric

any changes to the type of these columns in firestore will require modifying
Expand Down Expand Up @@ -115,8 +114,6 @@ export type Contract<T extends AnyContractType = AnyContractType> = {
/** @deprecated */
groupLinks?: GroupLink[]

/** @deprecated - not deprecated, only updated in supabase though*/
popularityScore: number
/** @deprecated - not deprecated, only updated in supabase though*/
importanceScore: number
/** @deprecated - not deprecated, only updated in supabase though*/
Expand Down
1 change: 0 additions & 1 deletion common/src/new-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export function getNewContract(props: {
createdTime,
closeTime,
dailyScore: 0,
popularityScore: 0,
importanceScore: NEW_MARKET_IMPORTANCE_SCORE,
freshnessScore: 0,
uniqueBettorCount: 0,
Expand Down
Loading