feat: more ts, fix tailwind

- rename more files to .ts/.tsx
- update tailwind config to use .tsx files from all dirs
- merge css files into a single main.css to avoid import order
  dependencies
- minor cleanups due to ts complaints
This commit is contained in:
Vyacheslav Matyukhin 2022-03-26 03:36:50 +03:00
parent 42c0f0967b
commit b481212721
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
70 changed files with 193 additions and 223 deletions

View File

@ -2,8 +2,8 @@ import {
mongoRead, mongoRead,
mongoReadWithReadCredentials, mongoReadWithReadCredentials,
mongoUpsert, mongoUpsert,
} from "./mongo-wrapper.js"; } from "./mongo-wrapper";
import { pgRead, pgReadWithReadCredentials, pgUpsert } from "./pg-wrapper.js"; import { pgRead, pgReadWithReadCredentials, pgUpsert } from "./pg-wrapper";
export async function databaseUpsert({ contents, group }) { export async function databaseUpsert({ contents, group }) {
// No, this should be more rational, ({contents, group, schema})? Or should this be managed by this layer? Unclear. // No, this should be more rational, ({contents, group, schema})? Or should this be managed by this layer? Unclear.

View File

@ -1,5 +1,5 @@
import pkg from "mongodb"; import pkg from "mongodb";
import { roughSizeOfObject } from "../utils/roughSize.js"; import { roughSizeOfObject } from "../utils/roughSize";
const { MongoClient } = pkg; const { MongoClient } = pkg;
export async function mongoUpsert( export async function mongoUpsert(

View File

@ -1,7 +1,7 @@
import pkg from "pg"; import pkg from "pg";
import { platformNames } from "../platforms/all/platformNames.js"; import { platformNames } from "../platforms/all/platformNames";
import { hash } from "../utils/hash.js"; import { hash } from "../utils/hash";
import { roughSizeOfObject } from "../utils/roughSize.js"; import { roughSizeOfObject } from "../utils/roughSize";
const { Pool } = pkg; const { Pool } = pkg;
// Definitions // Definitions

View File

@ -1,8 +1,8 @@
import { mergeEverything } from "./mergeEverything.js"; import { platformFetchers } from "../platforms/all-platforms";
import { updateHistory } from "./history/updateHistory.js"; import { rebuildAlgoliaDatabase } from "../utils/algolia";
import { rebuildAlgoliaDatabase } from "../utils/algolia.js"; import { updateHistory } from "./history/updateHistory";
import { rebuildNetlifySiteWithNewData } from "./rebuildNetliftySiteWithNewData.js"; import { mergeEverything } from "./mergeEverything";
import { platformFetchers } from "../platforms/all-platforms.js"; import { rebuildNetlifySiteWithNewData } from "./rebuildNetliftySiteWithNewData";
/* Do everything */ /* Do everything */
function sleep(ms) { function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms)); return new Promise((resolve) => setTimeout(resolve, ms));

View File

@ -1,3 +1,3 @@
import { doEverything } from "./doEverything.js"; import { doEverything } from "./doEverything";
doEverything(); doEverything();

View File

@ -1,8 +1,7 @@
import { writeFileSync } from "fs";
import { import {
databaseReadWithReadCredentials, databaseReadWithReadCredentials,
databaseUpsert, databaseUpsert,
} from "../../database/database-wrapper.js"; } from "../../database/database-wrapper";
let isEmptyArray = (arr) => arr.length == 0; let isEmptyArray = (arr) => arr.length == 0;
export async function addToHistory() { export async function addToHistory() {

View File

@ -1,7 +1,4 @@
import { import { databaseRead, databaseUpsert } from "../../database/database-wrapper";
databaseRead,
databaseUpsert,
} from "../../database/database-wrapper.js";
export async function createHistoryForMonth() { export async function createHistoryForMonth() {
let currentDate = new Date(); let currentDate = new Date();

View File

@ -1,4 +1,4 @@
import { databaseRead, databaseUpsert } from "../database-wrapper.js"; import { databaseRead, databaseUpsert } from "../database-wrapper";
let createInitialHistory = async () => { let createInitialHistory = async () => {
let metaforecasts = await databaseRead({ group: "combined" }); let metaforecasts = await databaseRead({ group: "combined" });

View File

@ -1,5 +1,5 @@
import { addToHistory } from "./addToHistory.js"; import { addToHistory } from "./addToHistory";
import { createHistoryForMonth } from "./createHistoryForMonth.js"; import { createHistoryForMonth } from "./createHistoryForMonth";
export async function updateHistoryOld() { export async function updateHistoryOld() {
let currentDate = new Date(); let currentDate = new Date();

View File

@ -1,7 +1,7 @@
import { import {
databaseReadWithReadCredentials, databaseReadWithReadCredentials,
databaseUpsert, databaseUpsert,
} from "../../database/database-wrapper.js"; } from "../../database/database-wrapper";
export async function updateHistory() { export async function updateHistory() {
let latest = await databaseReadWithReadCredentials({ group: "combined" }); let latest = await databaseReadWithReadCredentials({ group: "combined" });

View File

@ -1,5 +1,5 @@
import { databaseRead, databaseUpsert } from "../database/database-wrapper.js"; import { databaseRead, databaseUpsert } from "../database/database-wrapper";
import { platformNames } from "../platforms/all-platforms.js"; import { platformNames } from "../platforms/all-platforms";
/* Merge everything */ /* Merge everything */
export async function mergeEverythingInner() { export async function mergeEverythingInner() {

View File

@ -1,5 +1,5 @@
import axios from "axios"; import axios from "axios";
import { applyIfSecretExists } from "../utils/getSecrets.js"; import { applyIfSecretExists } from "../utils/getSecrets";
async function rebuildNetlifySiteWithNewData_inner(cookie) { async function rebuildNetlifySiteWithNewData_inner(cookie) {
let payload = {}; let payload = {};

View File

@ -3,14 +3,14 @@ import 'dotenv/config';
import readline from 'readline'; import readline from 'readline';
import { pgInitialize } from './database/pg-wrapper.js'; import { pgInitialize } from './database/pg-wrapper';
import { doEverything, tryCatchTryAgain } from './flow/doEverything.js'; import { doEverything, tryCatchTryAgain } from './flow/doEverything';
import { updateHistory } from './flow/history/updateHistory.js'; import { updateHistory } from './flow/history/updateHistory';
import { mergeEverything } from './flow/mergeEverything.js'; import { mergeEverything } from './flow/mergeEverything';
import { rebuildNetlifySiteWithNewData } from './flow/rebuildNetliftySiteWithNewData.js'; import { rebuildNetlifySiteWithNewData } from './flow/rebuildNetliftySiteWithNewData';
import { rebuildFrontpage } from './frontpage'; import { rebuildFrontpage } from './frontpage';
import { platformFetchers } from './platforms/all-platforms.js'; import { platformFetchers } from './platforms/all-platforms';
import { rebuildAlgoliaDatabase } from './utils/algolia.js'; import { rebuildAlgoliaDatabase } from './utils/algolia';
/* Support functions */ /* Support functions */
let functions = [ let functions = [

View File

@ -1,6 +1,6 @@
import "dotenv/config"; import "dotenv/config";
import fs from "fs"; import fs from "fs";
import { databaseReadWithReadCredentials } from "../database/database-wrapper.js"; import { databaseReadWithReadCredentials } from "../database/database-wrapper";
let main = async () => { let main = async () => {
let json = await databaseReadWithReadCredentials({ group: "combined" }); let json = await databaseReadWithReadCredentials({ group: "combined" });

View File

@ -1,3 +1,3 @@
import { pgInitialize } from "../database/pg-wrapper.js"; import { pgInitialize } from "../database/pg-wrapper";
pgInitialize(); pgInitialize();

View File

@ -1,5 +1,5 @@
import fs from "fs"; import fs from "fs";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
/* This is necessary for estimize, the database of x-risk estimates, and for the OpenPhil/GiveWell predictions. Unlike the others, I'm not fetching them constantly, but only once. */ /* This is necessary for estimize, the database of x-risk estimates, and for the OpenPhil/GiveWell predictions. Unlike the others, I'm not fetching them constantly, but only once. */

View File

@ -1,5 +1,5 @@
/* Imports */ /* Imports */
import { goodjudgment } from "../platforms/goodjudgment-fetch.js"; import { goodjudgment } from "../platforms/goodjudgment-fetch";
/* Definitions */ /* Definitions */

View File

@ -1,2 +1,2 @@
export { platformFetchers } from "./all/platformFetchers.js"; export { platformFetchers } from "./all/platformFetchers";
export { platformNames } from "./all/platformNames.js"; export { platformNames } from "./all/platformNames";

View File

@ -1,27 +1,27 @@
import { betfair } from "../betfair-fetch.js"; import { betfair } from "../betfair-fetch";
import { fantasyscotus } from "../fantasyscotus-fetch.js"; import { fantasyscotus } from "../fantasyscotus-fetch";
import { foretold } from "../foretold-fetch.js"; import { foretold } from "../foretold-fetch";
import { goodjudgment } from "../goodjudgment-fetch.js"; import { goodjudgment } from "../goodjudgment-fetch";
import { goodjudgmentopen } from "../goodjudmentopen-fetch.js"; import { goodjudgmentopen } from "../goodjudmentopen-fetch";
import { infer } from "../infer-fetch.js"; import { infer } from "../infer-fetch";
import { kalshi } from "../kalshi-fetch.js"; import { kalshi } from "../kalshi-fetch";
import { manifoldmarkets } from "../manifoldmarkets-fetch.js"; import { manifoldmarkets } from "../manifoldmarkets-fetch";
import { metaculus } from "../metaculus-fetch.js"; import { metaculus } from "../metaculus-fetch";
import { polymarket } from "../polymarket-fetch.js"; import { polymarket } from "../polymarket-fetch";
import { predictit } from "../predictit-fetch.js"; import { predictit } from "../predictit-fetch";
import { rootclaim } from "../rootclaim-fetch.js"; import { rootclaim } from "../rootclaim-fetch";
import { smarkets } from "../smarkets-fetch.js"; import { smarkets } from "../smarkets-fetch";
import { wildeford } from "../wildeford-fetch.js"; import { wildeford } from "../wildeford-fetch";
/* Deprecated /* Deprecated
import { astralcodexten } from "../platforms/astralcodexten-fetch.js" import { astralcodexten } from "../platforms/astralcodexten-fetch"
import { coupcast } from "../platforms/coupcast-fetch.js" import { coupcast } from "../platforms/coupcast-fetch"
import { csetforetell } from "../platforms/csetforetell-fetch.js" import { csetforetell } from "../platforms/csetforetell-fetch"
import { elicit } from "../platforms/elicit-fetch.js" import { elicit } from "../platforms/elicit-fetch"
import { estimize } from "../platforms/estimize-fetch.js" import { estimize } from "../platforms/estimize-fetch"
import { hypermind } from "../platforms/hypermind-fetch.js" import { hypermind } from "../platforms/hypermind-fetch"
import { ladbrokes } from "../platforms/ladbrokes-fetch.js"; import { ladbrokes } from "../platforms/ladbrokes-fetch";
import { williamhill } from "../platforms/williamhill-fetch.js"; import { williamhill } from "../platforms/williamhill-fetch";
*/ */
export const platformFetchers = [ export const platformFetchers = [

View File

@ -1,8 +1,8 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import https from "https"; import https from "https";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let endpoint = process.env.SECRET_BETFAIR_ENDPOINT; let endpoint = process.env.SECRET_BETFAIR_ENDPOINT;

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let graphQLendpoint = "https://api.foretold.io/graphql"; let graphQLendpoint = "https://api.foretold.io/graphql";

View File

@ -1,8 +1,8 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import Papa from "papaparse"; import Papa from "papaparse";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let coupCastEndpoint = let coupCastEndpoint =

View File

@ -1,10 +1,10 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { Tabletojson } from "tabletojson"; import { Tabletojson } from "tabletojson";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { applyIfSecretExists } from "../utils/getSecrets.js"; import { applyIfSecretExists } from "../utils/getSecrets";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
import toMarkdown from "../utils/toMarkdown.js"; import toMarkdown from "../utils/toMarkdown";
/* Definitions */ /* Definitions */
let htmlEndPoint = "https://www.cset-foretell.com/questions?page="; let htmlEndPoint = "https://www.cset-foretell.com/questions?page=";

View File

@ -2,8 +2,8 @@
import axios from "axios"; import axios from "axios";
import Papa from "papaparse"; import Papa from "papaparse";
import readline from "readline"; import readline from "readline";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let elicitEndpoint = let elicitEndpoint =

View File

@ -1,6 +1,6 @@
import fs from "fs"; import fs from "fs";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
export async function estimize() { export async function estimize() {
let data = fs.readFileSync( let data = fs.readFileSync(

View File

@ -1,10 +1,10 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import https from "https"; import https from "https";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { applyIfSecretExists } from "../utils/getSecrets.js"; import { applyIfSecretExists } from "../utils/getSecrets";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
import toMarkdown from "../utils/toMarkdown.js"; import toMarkdown from "../utils/toMarkdown";
/* Definitions */ /* Definitions */
let hypermindEnpoint1 = "https://predict.hypermind.com/dash/jsx.json"; let hypermindEnpoint1 = "https://predict.hypermind.com/dash/jsx.json";

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let endpointPolitics = `https://ss-aka-ori.ladbrokes.com/openbet-ssviewer/Drilldown/2.31/EventToOutcomeForClass/302,301,300?simpleFilter=event.siteChannels:contains:M&simpleFilter=event.eventSortCode:intersects:TNMT,TR01,TR02,TR03,TR04,TR05,TR06,TR07,TR08,TR09,TR10,TR11,TR12,TR13,TR14,TR15,TR16,TR17,TR18,TR19,TR20&simpleFilter=event.suspendAtTime:greaterThan:${new Date().toISOString()}.000Z&limitRecords=outcome:1&limitRecords=market:1&translationLang=en&responseFormat=json&prune=event&prune=market`; let endpointPolitics = `https://ss-aka-ori.ladbrokes.com/openbet-ssviewer/Drilldown/2.31/EventToOutcomeForClass/302,301,300?simpleFilter=event.siteChannels:contains:M&simpleFilter=event.eventSortCode:intersects:TNMT,TR01,TR02,TR03,TR04,TR05,TR06,TR07,TR08,TR09,TR10,TR11,TR12,TR13,TR14,TR15,TR16,TR17,TR18,TR19,TR20&simpleFilter=event.suspendAtTime:greaterThan:${new Date().toISOString()}.000Z&limitRecords=outcome:1&limitRecords=market:1&translationLang=en&responseFormat=json&prune=event&prune=market`;

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../../utils/database-wrapper.js"; import { databaseUpsert } from "../../utils/database-wrapper";
import { calculateStars } from "../../utils/stars.js"; import { calculateStars } from "../../utils/stars";
/* Definitions */ /* Definitions */
let graphQLendpoint = "https://api.thegraph.com/subgraphs/name/protofire/omen"; let graphQLendpoint = "https://api.thegraph.com/subgraphs/name/protofire/omen";

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../utils/database-wrapper.js"; import { databaseUpsert } from "../utils/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let endpoint = "https://sports.williamhill.com/betting/en-gb/politics"; let endpoint = "https://sports.williamhill.com/betting/en-gb/politics";

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let endpoint = "https://example.com/"; let endpoint = "https://example.com/";

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let unixtime = new Date().getTime(); let unixtime = new Date().getTime();

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let graphQLendpoint = "https://api.foretold.io/graphql"; let graphQLendpoint = "https://api.foretold.io/graphql";

View File

@ -1,8 +1,8 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import fs from "fs"; import fs from "fs";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Support functions */ /* Support functions */
async function fetchPage(url) { async function fetchPage(url) {

View File

@ -2,9 +2,9 @@
import axios from "axios"; import axios from "axios";
import { Tabletojson } from "tabletojson"; import { Tabletojson } from "tabletojson";
import tunnel from "tunnel"; import tunnel from "tunnel";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { hash } from "../utils/hash.js"; import { hash } from "../utils/hash";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let endpoint = "https://goodjudgment.io/superforecasts/"; let endpoint = "https://goodjudgment.io/superforecasts/";

View File

@ -1,10 +1,10 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { Tabletojson } from "tabletojson"; import { Tabletojson } from "tabletojson";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { applyIfSecretExists } from "../utils/getSecrets.js"; import { applyIfSecretExists } from "../utils/getSecrets";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
import toMarkdown from "../utils/toMarkdown.js"; import toMarkdown from "../utils/toMarkdown";
/* Definitions */ /* Definitions */
let htmlEndPoint = "https://www.gjopen.com/questions?page="; let htmlEndPoint = "https://www.gjopen.com/questions?page=";

View File

@ -1,10 +1,10 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { Tabletojson } from "tabletojson"; import { Tabletojson } from "tabletojson";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { applyIfSecretExists } from "../utils/getSecrets.js"; import { applyIfSecretExists } from "../utils/getSecrets";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
import toMarkdown from "../utils/toMarkdown.js"; import toMarkdown from "../utils/toMarkdown";
/* Definitions */ /* Definitions */
let htmlEndPoint = "https://www.infer-pub.com/questions"; let htmlEndPoint = "https://www.infer-pub.com/questions";

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let jsonEndpoint = "https://trading-api.kalshi.com/v1/cached/markets/"; //"https://subgraph-matic.poly.market/subgraphs/name/TokenUnion/polymarket"//"https://subgraph-backup.poly.market/subgraphs/name/TokenUnion/polymarket"//'https://subgraph-matic.poly.market/subgraphs/name/TokenUnion/polymarket3' let jsonEndpoint = "https://trading-api.kalshi.com/v1/cached/markets/"; //"https://subgraph-matic.poly.market/subgraphs/name/TokenUnion/polymarket"//"https://subgraph-backup.poly.market/subgraphs/name/TokenUnion/polymarket"//'https://subgraph-matic.poly.market/subgraphs/name/TokenUnion/polymarket3'

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let endpoint = "https://manifold.markets/api/v0/markets"; let endpoint = "https://manifold.markets/api/v0/markets";

View File

@ -1,8 +1,8 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
import toMarkdown from "../utils/toMarkdown.js"; import toMarkdown from "../utils/toMarkdown";
/* Definitions */ /* Definitions */
let jsonEndPoint = "https://www.metaculus.com/api2/questions/?page="; let jsonEndPoint = "https://www.metaculus.com/api2/questions/?page=";

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let graphQLendpoint = let graphQLendpoint =

View File

@ -1,8 +1,8 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
import toMarkdown from "../utils/toMarkdown.js"; import toMarkdown from "../utils/toMarkdown";
/* Support functions */ /* Support functions */
async function fetchmarkets() { async function fetchmarkets() {

View File

@ -1,8 +1,8 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
import toMarkdown from "../utils/toMarkdown.js"; import toMarkdown from "../utils/toMarkdown";
/* Definitions */ /* Definitions */
let jsonEndpoint = let jsonEndpoint =

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import axios from "axios"; import axios from "axios";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
let htmlEndPointEntrance = "https://api.smarkets.com/v3/events/"; let htmlEndPointEntrance = "https://api.smarkets.com/v3/events/";

View File

@ -1,10 +1,10 @@
/* Imports */ /* Imports */
// import axios from "axios" // import axios from "axios"
import { GoogleSpreadsheet } from "google-spreadsheet"; import { GoogleSpreadsheet } from "google-spreadsheet";
import { databaseUpsert } from "../database/database-wrapper.js"; import { databaseUpsert } from "../database/database-wrapper";
import { applyIfSecretExists } from "../utils/getSecrets.js"; import { applyIfSecretExists } from "../utils/getSecrets";
import { hash } from "../utils/hash.js"; import { hash } from "../utils/hash";
import { calculateStars } from "../utils/stars.js"; import { calculateStars } from "../utils/stars";
/* Definitions */ /* Definitions */
const SHEET_ID = "1xcgYF7Q0D95TPHLLSgwhWBHFrWZUGJn7yTyAhDR4vi0"; // spreadsheet key is the long id in the sheets URL const SHEET_ID = "1xcgYF7Q0D95TPHLLSgwhWBHFrWZUGJn7yTyAhDR4vi0"; // spreadsheet key is the long id in the sheets URL

View File

@ -1,6 +1,6 @@
import algoliasearch from "algoliasearch"; import algoliasearch from "algoliasearch";
import { databaseReadWithReadCredentials } from "../database/database-wrapper.js"; import { databaseReadWithReadCredentials } from "../database/database-wrapper";
import { mergeEverythingInner } from "../flow/mergeEverything.js"; import { mergeEverythingInner } from "../flow/mergeEverything";
let cookie = process.env.ALGOLIA_MASTER_API_KEY; let cookie = process.env.ALGOLIA_MASTER_API_KEY;
const client = algoliasearch("96UD3NTQ7L", cookie); const client = algoliasearch("96UD3NTQ7L", cookie);

View File

@ -1,6 +1,6 @@
/* Imports */ /* Imports */
import fs from "fs"; import fs from "fs";
import { databaseReadWithReadCredentials } from "../database-wrapper.js"; import { databaseReadWithReadCredentials } from "../database-wrapper";
/* Definitions */ /* Definitions */

View File

@ -1,6 +1,6 @@
/* Imports */ /* Imports */
import fs from "fs"; import fs from "fs";
import { databaseReadWithReadCredentials } from "../database-wrapper.js"; import { databaseReadWithReadCredentials } from "../database-wrapper";
/* Definitions */ /* Definitions */

View File

@ -1,6 +1,6 @@
/* Imports */ /* Imports */
import fs from "fs"; import fs from "fs";
import { databaseReadWithReadCredentials } from "../database-wrapper.js"; import { databaseReadWithReadCredentials } from "../database-wrapper";
/* Definitions */ /* Definitions */
let locationData = "./data/"; let locationData = "./data/";

View File

@ -1,5 +1,4 @@
import "../styles/tailwind.css"; import '../styles/main.css';
import "../styles/globals.css";
function MyApp({ Component, pageProps }) { function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />; return <Component {...pageProps} />;

View File

@ -1,7 +1,9 @@
import React from "react"; import React from 'react';
import ReactMarkdown from "react-markdown"; import ReactMarkdown from 'react-markdown';
import gfm from "remark-gfm"; import gfm from 'remark-gfm';
import Layout from "./layout.js";
import Layout from './layout';
let readmeMarkdownText = `# About let readmeMarkdownText = `# About
This is a search engine for probabilities. Given a query, it searches for relevant questions in various prediction markets and forecasting platforms (namely Betfair, FantasySCOTUS, Foretold, Good Judgment, Good Judgment Open, Guesstimate, GiveWell & OpenPhilanthropy blogposts as of early 2021, Kalshi, Infer, Ladbrokes, Manifold Markets, Metaculus, Polymarket, PredictIt, Smarkets, William Hill, and Michael Aird's database of existential risk estimates). For example, try searching for "China", "North Korea", "Semiconductors", "COVID", "Trump", or "X-risk". This is a search engine for probabilities. Given a query, it searches for relevant questions in various prediction markets and forecasting platforms (namely Betfair, FantasySCOTUS, Foretold, Good Judgment, Good Judgment Open, Guesstimate, GiveWell & OpenPhilanthropy blogposts as of early 2021, Kalshi, Infer, Ladbrokes, Manifold Markets, Metaculus, Polymarket, PredictIt, Smarkets, William Hill, and Michael Aird's database of existential risk estimates). For example, try searching for "China", "North Korea", "Semiconductors", "COVID", "Trump", or "X-risk".
@ -26,18 +28,11 @@ Also note that, whatever other redeeming features they might have, prediction ma
export default function About() { export default function About() {
return ( return (
<Layout <Layout page="about">
key="index"
page="about"
lastUpdated={null}
captureToggle={null}
switchCaptureToggle={() => null}
>
<div className="px-2 py-2 bg-white rounded-md shadow place-content-stretch flex-grow place-self-center"> <div className="px-2 py-2 bg-white rounded-md shadow place-content-stretch flex-grow place-self-center">
<ReactMarkdown <ReactMarkdown
plugins={[gfm]} remarkPlugins={[gfm]}
children={readmeMarkdownText} children={readmeMarkdownText}
allowDangerousHtml
className="m-5" className="m-5"
/> />
</div> </div>

View File

@ -1,8 +1,9 @@
import Head from "next/head"; import Head from 'next/head';
import Link from "next/link"; import Link from 'next/link';
import React from "react"; import React from 'react';
// import { GiDiceEightFacesEight } from "react-icons/gi"; // import { GiDiceEightFacesEight } from "react-icons/gi";
import { Logo2 } from "../web/icons/index.js"; import { Logo2 } from '../web/icons/index';
/* Utilities */ /* Utilities */
const classNameSelected = (isSelected) => const classNameSelected = (isSelected) =>
@ -25,7 +26,10 @@ let calculateLastUpdate = () => {
}; };
// Error catcher // Error catcher
class ErrorBoundary extends React.Component { class ErrorBoundary extends React.Component<
any,
{ error: any; errorInfo: any }
> {
// https://reactjs.org/docs/error-boundaries.html // https://reactjs.org/docs/error-boundaries.html
constructor(props) { constructor(props) {
super(props); super(props);
@ -78,7 +82,7 @@ export default function Layout({ page, children }) {
// https://developer.mozilla.org/en-US/docs/Web/API/Location/assign // https://developer.mozilla.org/en-US/docs/Web/API/Location/assign
// window.location.hostname // window.location.hostname
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
if (window.location != window.location.pathname) { if ((window.location as any) != window.location.pathname) {
window.location.assign(window.location.pathname); window.location.assign(window.location.pathname);
} }
} }

View File

@ -1,4 +1,4 @@
import React, { useEffect } from "react"; import React, { useEffect } from 'react';
function Recursion() { function Recursion() {
useEffect(() => { useEffect(() => {

View File

@ -4,7 +4,7 @@
import { useRouter } from "next/router"; // https://nextjs.org/docs/api-reference/next/router import { useRouter } from "next/router"; // https://nextjs.org/docs/api-reference/next/router
import React, { useState } from "react"; import React, { useState } from "react";
// Data // Data
import displayForecasts from "../web/display/displayForecasts.js"; import displayForecasts from "../web/display/displayForecasts";
import { getDashboardForecastsByDashboardId } from "../web/worker/getDashboardForecasts"; import { getDashboardForecastsByDashboardId } from "../web/worker/getDashboardForecasts";
/* get Props */ /* get Props */

View File

@ -2,7 +2,7 @@
import React from 'react'; import React from 'react';
import { displayForecast } from '../web/display/displayForecasts.js'; import { displayForecast } from '../web/display/displayForecasts';
import { platformsWithLabels } from '../web/platforms'; import { platformsWithLabels } from '../web/platforms';
import searchAccordingToQueryData from '../web/worker/searchAccordingToQueryData'; import searchAccordingToQueryData from '../web/worker/searchAccordingToQueryData';

View File

@ -1,34 +1,18 @@
import React, { useState } from "react"; import Link from 'next/link';
import Link from "next/link"; import React from 'react';
import Layout from "./layout.js";
/* Helper functions */ import Layout from './layout';
let calculateLastUpdate = () => {
let today = new Date().toISOString();
let yesterdayObj = new Date();
yesterdayObj.setDate(yesterdayObj.getDate() - 1);
let yesterday = yesterdayObj.toISOString();
if (today.slice(11, 16) > "02:00") {
return today.slice(0, 10);
} else {
return yesterday.slice(0, 10);
}
};
/* get Props */
export async function getStaticProps() {
//getServerSideProps
let lastUpdated = calculateLastUpdate(); // metaforecasts.find(forecast => forecast.platform == "Good Judgment Open").timestamp
return {
props: {
lastUpdated,
},
};
}
/* Display one tool */ /* Display one tool */
function displayTool({ sameWebpage, title, description, link, url, img, i }) { function displayTool({
sameWebpage,
title,
description,
link,
url,
img,
i,
}: any) {
switch (sameWebpage) { switch (sameWebpage) {
case true: case true:
return ( return (
@ -50,7 +34,6 @@ function displayTool({ sameWebpage, title, description, link, url, img, i }) {
return ( return (
<a <a
href={url} href={url}
passHref
key={`tool-${i}`} key={`tool-${i}`}
className="hover:bg-gray-100 hover:no-underline cursor-pointer flex flex-col px-4 py-3 bg-white rounded-md shadow place-content-stretch flex-grow no-underline b-6" className="hover:bg-gray-100 hover:no-underline cursor-pointer flex flex-col px-4 py-3 bg-white rounded-md shadow place-content-stretch flex-grow no-underline b-6"
> >
@ -111,12 +94,7 @@ export default function Tools({ lastUpdated }) {
}, },
]; ];
return ( return (
<Layout <Layout page="tools">
key="tools"
page="tools"
lastUpdated={lastUpdated}
captureToggle={"search"}
>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 mb-8"> <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 mb-8">
{tools.map((tool, i) => displayTool({ ...tool, i }))} {tools.map((tool, i) => displayTool({ ...tool, i }))}
</div> </div>

View File

@ -1,3 +1,11 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
.text-orange-400 {
color: #ffac75;
}
html, html,
body { body {
padding: 0; padding: 0;

View File

@ -1,7 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
.text-orange-400 {
color: #ffac75;
}

View File

@ -1,4 +1,4 @@
import React, { useState } from "react"; import React, { useState } from 'react';
let exampleInput = `{ let exampleInput = `{
"title": "Random example", "title": "Random example",
@ -54,8 +54,8 @@ Your old input was: ${value}`;
<textarea <textarea
value={value} value={value}
onChange={handleChange} onChange={handleChange}
rows="8" rows={8}
cols="50" cols={50}
className="" className=""
/> />
<br /> <br />

View File

@ -1,7 +1,7 @@
/* Imports */ /* Imports */
import React, { useState } from "react"; import React from 'react';
import ReactMarkdown from "react-markdown"; import { FaRegClipboard } from 'react-icons/fa';
import { FaRegClipboard } from "react-icons/fa"; import ReactMarkdown from 'react-markdown';
/* Definitions */ /* Definitions */
@ -603,8 +603,8 @@ export function displayForecast({
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
navigator.clipboard.writeText(`"${id}"`); navigator.clipboard.writeText(`"${id}"`);
setIsJustCopiedSignalVisible(true); // setIsJustCopiedSignalVisible(true);
setTimeout(() => setIsJustCopiedSignalVisible(false), 1000); // setTimeout(() => setIsJustCopiedSignalVisible(false), 1000);
// This is just personal preference. // This is just personal preference.
// I prefer to not show the whole text area selected. // I prefer to not show the whole text area selected.
}} }}

View File

@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard'; import { CopyToClipboard } from 'react-copy-to-clipboard';
import { uploadToImgur } from '../worker/uploadToImgur'; import { uploadToImgur } from '../worker/uploadToImgur';
import { displayForecast } from './displayForecasts.js'; import { displayForecast } from './displayForecasts';
function displayOneForecastInner(result, containerRef) { function displayOneForecastInner(result, containerRef) {
return ( return (

View File

@ -1,4 +1,4 @@
import React, { useState } from "react"; import React from 'react';
export default function DropdownForStars({ export default function DropdownForStars({
value, value,

View File

@ -1,4 +1,4 @@
import React, { useRef } from "react"; import React from 'react';
export default function Form({ value, onChange, placeholder }) { export default function Form({ value, onChange, placeholder }) {
const handleInputChange = (event) => { const handleInputChange = (event) => {
@ -16,7 +16,6 @@ export default function Form({ value, onChange, placeholder }) {
onChange={handleInputChange} onChange={handleInputChange}
name="query" name="query"
id="query" id="query"
label="Query"
placeholder={placeholder} placeholder={placeholder}
onSubmit={(e) => e.preventDefault()} onSubmit={(e) => e.preventDefault()}
/> />

View File

@ -1,7 +1,8 @@
import chroma from "chroma-js"; import chroma from 'chroma-js';
import React from "react"; import React from 'react';
import Select from "react-select"; import Select from 'react-select';
import { platformsWithLabels } from "../platforms";
import { platformsWithLabels } from '../platforms';
const colourStyles = { const colourStyles = {
control: (styles) => ({ ...styles, backgroundColor: "white" }), control: (styles) => ({ ...styles, backgroundColor: "white" }),

View File

@ -1,6 +1,7 @@
/* Imports */ /* Imports */
import { Slider, Rail, Handles, Tracks, Ticks } from "react-compound-slider"; import React from 'react';
import React, { useState } from "react"; import { Handles, Rail, Slider, Tracks } from 'react-compound-slider';
// https://sghall.github.io/react-compound-slider/#/getting-started/tutorial // https://sghall.github.io/react-compound-slider/#/getting-started/tutorial
/* Definitions */ /* Definitions */

View File

@ -1,4 +1,4 @@
import * as React from "react"; import * as React from 'react';
function SvgFavicon(props) { function SvgFavicon(props) {
return ( return (

View File

@ -1,4 +1,4 @@
import * as React from "react"; import * as React from 'react';
function SvgLogo(props) { function SvgLogo(props) {
return ( return (

View File

@ -1,4 +1,4 @@
import * as React from "react"; import * as React from 'react';
function SvgLogo2(props) { function SvgLogo2(props) {
return ( return (

View File

@ -1,5 +1,5 @@
import searchGuesstimate from './searchGuesstimate.js'; import searchGuesstimate from './searchGuesstimate';
import searchWithAlgolia from './searchWithAlgolia.js'; import searchWithAlgolia from './searchWithAlgolia';
export default async function searchAccordingToQueryData(queryData) { export default async function searchAccordingToQueryData(queryData) {
let results = []; let results = [];

View File

@ -1,9 +1,5 @@
module.exports = { module.exports = {
content: [ content: ["./src/web/**/*.tsx", "./src/pages/**/*.tsx"],
"./src/pages/**/*.{js,ts,jsx,tsx}",
"./src/web/display/**/*.{js,ts,jsx,tsx}",
"./src/web/icons/**/*.{js,ts,jsx,tsx}",
],
darkMode: "media", // or 'media' or 'class' darkMode: "media", // or 'media' or 'class'
theme: { theme: {
extend: { extend: {