Skip to content
Merged
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
1 change: 1 addition & 0 deletions front_end/messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1817,5 +1817,6 @@
"tournamentsTabIndexes": "Indexy",
"tournamentsTabArchived": "Archivováno",
"tournamentTimelineClosed": "Čekání na vyřešení",
"questionsPreviouslyPredicted": "{count, plural, =1 {# otázka} other {# otázek}} dříve předpovězených",
"othersCount": "Ostatní ({count})"
}
1 change: 1 addition & 0 deletions front_end/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@
"questionsTotal": "{count} questions total",
"reviewAll": "Review all",
"questionsNotPredicted": "{count, plural, =1 {# question} other {# questions}} not predicted",
"questionsPreviouslyPredicted": "{count, plural, =1 {# question} other {# questions}} previously predicted",
"significantMovementForecasts": "{count, plural, =1 {# forecast} other {# forecasts}} with significant movement",
"stalePredictions": "{count, plural, =1 {# prediction} other {# predictions}} might be stale",
"allQuestionsPredicted": "All questions predicted",
Expand Down
1 change: 1 addition & 0 deletions front_end/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1817,5 +1817,6 @@
"tournamentsTabIndexes": "Índices",
"tournamentsTabArchived": "Archivado",
"tournamentTimelineClosed": "Esperando resoluciones",
"questionsPreviouslyPredicted": "{count, plural, =1 {# pregunta} other {# preguntas}} previamente previstas",
"othersCount": "Otros ({count})"
}
1 change: 1 addition & 0 deletions front_end/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1815,5 +1815,6 @@
"tournamentsTabIndexes": "Índices",
"tournamentsTabArchived": "Arquivado",
"tournamentTimelineClosed": "Aguardando resoluções",
"questionsPreviouslyPredicted": "{count, plural, =1 {# pergunta} other {# perguntas}} previamente previstas",
"othersCount": "Outros ({count})"
}
1 change: 1 addition & 0 deletions front_end/messages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1814,5 +1814,6 @@
"tournamentsTabIndexes": "指數",
"tournamentsTabArchived": "已存檔",
"tournamentTimelineClosed": "等待裁定",
"questionsPreviouslyPredicted": "先前預測的{count, plural, =1 {# 個問題} other {# 個問題}}",
"withdrawAfterPercentSetting2": "問題總生命周期後撤回"
}
1 change: 1 addition & 0 deletions front_end/messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1819,5 +1819,6 @@
"tournamentsTabIndexes": "索引",
"tournamentsTabArchived": "已归档",
"tournamentTimelineClosed": "等待解决",
"questionsPreviouslyPredicted": "之前预测的{count, plural, =1 {# 个问题} other {# 个问题}}",
"othersCount": "其他({count})"
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,24 @@ const ParticipationBlock: FC<Props> = ({ tournament, posts }) => {
isPostOpenQuestionPredicted(post, {
checkAllSubquestions: false,
treatClosedAsPredicted: false,
treatWithdrawnAsPredicted: true,
})
);
const unpredictedPosts: PredictionFlowPost[] = [];
const withdrawnPosts: PredictionFlowPost[] = [];
const stalePredictionsPosts: PredictionFlowPost[] = [];
const significantMovementPosts: PredictionFlowPost[] = [];

posts.forEach((post) => {
if (!isPostOpenQuestionPredicted(post)) {
// Check if post has withdrawn forecasts (was predicted but now inactive)
const hasWithdrawnForecast = isPostOpenQuestionPredicted(post, {
treatWithdrawnAsPredicted: true,
});
const hasActiveForecast = isPostOpenQuestionPredicted(post);

if (hasWithdrawnForecast && !hasActiveForecast) {
withdrawnPosts.push(post);
} else if (!hasActiveForecast) {
unpredictedPosts.push(post);
}
if (isPostStale(post)) {
Expand All @@ -79,6 +89,7 @@ const ParticipationBlock: FC<Props> = ({ tournament, posts }) => {
});
const isRequireAttention =
!!unpredictedPosts.length ||
!!withdrawnPosts.length ||
!!stalePredictionsPosts.length ||
!!significantMovementPosts.length;

Expand Down Expand Up @@ -108,6 +119,16 @@ const ParticipationBlock: FC<Props> = ({ tournament, posts }) => {
icon={faExclamationTriangle}
/>
)}
{/* Withdrawn questions */}
{!!withdrawnPosts.length && (
<ParticipationBlockLink
href={`/tournament/${tournamentSlug}/prediction-flow?flow_type=${FlowType.NOT_PREDICTED}`}
text={t("questionsPreviouslyPredicted", {
count: withdrawnPosts.length,
})}
icon={faClock}
/>
)}
{/* Significant movement forecasts */}
{!!significantMovementPosts.length && (
<ParticipationBlockLink
Expand Down
4 changes: 2 additions & 2 deletions front_end/src/app/(prediction-flow)/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const PredictionFlowHeader: FC<Props> = ({
</h1>
</Link>
</div>
<p className="m-0 mx-3 max-w-[255px] truncate text-lg leading-7">
<div className="m-0 mx-3 max-w-[255px] truncate text-lg leading-7 md:absolute md:left-1/2 md:mx-0 md:max-w-[350px] md:-translate-x-1/2">
{tournamentName}
</p>
</div>
<Button
className="mr-2 hidden sm:block"
onClick={() => {
Expand Down
27 changes: 19 additions & 8 deletions front_end/src/utils/forecasts/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,17 @@ export const isPostOpenQuestionPredicted = (
config?: {
checkAllSubquestions?: boolean;
treatClosedAsPredicted?: boolean;
treatWithdrawnAsPredicted?: boolean;
}
) => {
const { checkAllSubquestions = true, treatClosedAsPredicted = true } =
config ?? {};
const {
checkAllSubquestions = true,
treatClosedAsPredicted = true,
treatWithdrawnAsPredicted = false,
} = config ?? {};
const openQuestionConfig = {
treatClosedAsPredicted,
treatWithdrawnAsPredicted,
};
if (post.question) {
return isOpenQuestionPredicted(post.question, openQuestionConfig);
Expand Down Expand Up @@ -134,18 +139,24 @@ export function isForecastActive(forecast: UserForecast | AggregateForecast) {

export function isOpenQuestionPredicted(
question: Question,
config?: { treatClosedAsPredicted?: boolean }
config?: {
treatClosedAsPredicted?: boolean;
treatWithdrawnAsPredicted?: boolean;
}
) {
const { treatClosedAsPredicted = true } = config ?? {};
const { treatClosedAsPredicted = true, treatWithdrawnAsPredicted = false } =
config ?? {};
const isForecastPredicted = (forecast: UserForecast | undefined) =>
!isNil(forecast) &&
(treatWithdrawnAsPredicted || isForecastActive(forecast));

return (
(treatClosedAsPredicted
? question.status !== QuestionStatus.OPEN
: false) ||
(question.status === QuestionStatus.OPEN &&
!isNil(question.my_forecasts?.latest) &&
isForecastActive(question.my_forecasts.latest)) ||
isForecastPredicted(question.my_forecasts?.latest)) ||
(question.status === QuestionStatus.OPEN &&
!isNil(question.my_forecast?.latest) &&
isForecastActive(question.my_forecast.latest))
isForecastPredicted(question.my_forecast?.latest))
);
}