Skip to content

Commit

Permalink
single quote
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 1, 2023
1 parent 83d7bad commit a1d40ea
Show file tree
Hide file tree
Showing 133 changed files with 3,773 additions and 3,734 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
directory: '/'
schedule:
interval: daily
open-pull-requests-limit: 10
Expand Down
96 changes: 48 additions & 48 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
/**
* File managing configuration for the application
* */
const dotenv = require("dotenv");
const fs = require("fs");
const dotenv = require('dotenv');
const fs = require('fs');

if (fs.existsSync(".env")) {
if (fs.existsSync('.env')) {
dotenv.config();
}

const defaults = {
STEAM_API_KEY: "", // for API reqs, in worker
STEAM_USER: "", // for getting replay salt/profile data, in retriever
STEAM_PASS: "",
ROLE: "", // for specifying the file that should be run when entry point is invoked
GROUP: "", // for specifying the group of apps that should be run when entry point is invoked
START_SEQ_NUM: "", // truthy: use sequence number stored in redis, else: use approximate value from live API
PROVIDER: "", // The cloud provider used by the application (determines how environment data is downloaded)
STEAM_ACCOUNT_DATA: "", // The URL to read Steam account data from
NODE_ENV: "development",
FRONTEND_PORT: "5000",
RETRIEVER_PORT: "5100",
PARSER_PORT: "5200",
PROXY_PORT: "5300",
ROOT_URL: "http://localhost:5000", // base url to redirect to after steam oauth login
RETRIEVER_HOST: "localhost:5100", // Comma separated list of retriever hosts (access to Dota 2 GC data)
GCDATA_RETRIEVER_HOST: "", // Comma separated list of retriever hosts dedicated for gcdata job
PARSER_HOST: "http://localhost:5600", // host of the parse server
UI_HOST: "", // The host of the UI, target of /logout and /return
PROXY_URLS: "", // comma separated list of proxy urls to use
STEAM_API_HOST: "api.steampowered.com", // comma separated list of hosts to fetch Steam API data from
POSTGRES_URL: "postgresql://postgres:postgres@localhost/yasp", // connection string for PostgreSQL
POSTGRES_TEST_URL: "postgresql://postgres:postgres@localhost/yasp_test",
READONLY_POSTGRES_URL: "postgresql://readonly:readonly@localhost/yasp", // readonly connection string for PostgreSQL
REDIS_URL: "redis://127.0.0.1:6379/0", // connection string for Redis
REDIS_TEST_URL: "redis://127.0.0.1:6379/1",
CASSANDRA_URL: "cassandra://localhost/yasp", // connection string for Cassandra
CASSANDRA_TEST_URL: "cassandra://localhost/yasp_test",
ELASTICSEARCH_URL: "localhost:9200",
INIT_POSTGRES_HOST: "localhost",
INIT_CASSANDRA_HOST: "localhost",
RETRIEVER_SECRET: "", // string to use as shared secret with retriever/parser
SESSION_SECRET: "secret to encrypt cookies with", // string to encrypt cookies
COOKIE_DOMAIN: "", // domain to use for the cookie. Use e.g. '.opendota.com' to share cookie across subdomains
STEAM_API_KEY: '', // for API reqs, in worker
STEAM_USER: '', // for getting replay salt/profile data, in retriever
STEAM_PASS: '',
ROLE: '', // for specifying the file that should be run when entry point is invoked
GROUP: '', // for specifying the group of apps that should be run when entry point is invoked
START_SEQ_NUM: '', // truthy: use sequence number stored in redis, else: use approximate value from live API
PROVIDER: '', // The cloud provider used by the application (determines how environment data is downloaded)
STEAM_ACCOUNT_DATA: '', // The URL to read Steam account data from
NODE_ENV: 'development',
FRONTEND_PORT: '5000',
RETRIEVER_PORT: '5100',
PARSER_PORT: '5200',
PROXY_PORT: '5300',
ROOT_URL: 'http://localhost:5000', // base url to redirect to after steam oauth login
RETRIEVER_HOST: 'localhost:5100', // Comma separated list of retriever hosts (access to Dota 2 GC data)
GCDATA_RETRIEVER_HOST: '', // Comma separated list of retriever hosts dedicated for gcdata job
PARSER_HOST: 'http://localhost:5600', // host of the parse server
UI_HOST: '', // The host of the UI, target of /logout and /return
PROXY_URLS: '', // comma separated list of proxy urls to use
STEAM_API_HOST: 'api.steampowered.com', // comma separated list of hosts to fetch Steam API data from
POSTGRES_URL: 'postgresql://postgres:postgres@localhost/yasp', // connection string for PostgreSQL
POSTGRES_TEST_URL: 'postgresql://postgres:postgres@localhost/yasp_test',
READONLY_POSTGRES_URL: 'postgresql://readonly:readonly@localhost/yasp', // readonly connection string for PostgreSQL
REDIS_URL: 'redis://127.0.0.1:6379/0', // connection string for Redis
REDIS_TEST_URL: 'redis://127.0.0.1:6379/1',
CASSANDRA_URL: 'cassandra://localhost/yasp', // connection string for Cassandra
CASSANDRA_TEST_URL: 'cassandra://localhost/yasp_test',
ELASTICSEARCH_URL: 'localhost:9200',
INIT_POSTGRES_HOST: 'localhost',
INIT_CASSANDRA_HOST: 'localhost',
RETRIEVER_SECRET: '', // string to use as shared secret with retriever/parser
SESSION_SECRET: 'secret to encrypt cookies with', // string to encrypt cookies
COOKIE_DOMAIN: '', // domain to use for the cookie. Use e.g. '.opendota.com' to share cookie across subdomains
UNTRACK_DAYS: 30, // The number of days a user is tracked for after every visit
GOAL: 5, // The cheese goal
DEFAULT_DELAY: 1000, // delay between API requests
Expand All @@ -54,24 +54,24 @@ const defaults = {
PUBLIC_SAMPLE_PERCENT: 10, // percent of public matches to sample in DB
SCENARIOS_SAMPLE_PERCENT: 100, // percent of parsed matches to sample for scenarios
BENCHMARKS_SAMPLE_PERCENT: 100, // percent of parsed matches to sample for benchmarks
ENABLE_MATCH_CACHE: "", // set to enable caching matches in Redis
ENABLE_MATCH_CACHE: '', // set to enable caching matches in Redis
ENABLE_PLAYER_CACHE: 1, // enable/disable player aggregation caching
ENABLE_RANDOM_MMR_UPDATE: "", // set to request MMR updates after ranked matches
ENABLE_RANDOM_MMR_UPDATE: '', // set to request MMR updates after ranked matches
MAXIMUM_AGE_SCENARIOS_ROWS: 4, // maximum allowed age of scenarios rows in weeks
MATCH_CACHE_SECONDS: 60, // number of seconds to cache matches
PLAYER_CACHE_SECONDS: 1800, // number of seconds to cache player aggregations
SCANNER_PLAYER_PERCENT: 100, // percent of matches from scanner to insert player account IDs for (discover new player account IDs)
ENABLE_RETRIEVER_ADVANCED_AUTH: "", // set to enable retriever two-factor and SteamGuard authentication,
ENABLE_API_LIMIT: "", // if truthy, API calls after exceeding API_FREE_LIMIT are blocked
ENABLE_RETRIEVER_ADVANCED_AUTH: '', // set to enable retriever two-factor and SteamGuard authentication,
ENABLE_API_LIMIT: '', // if truthy, API calls after exceeding API_FREE_LIMIT are blocked
API_FREE_LIMIT: 50000, // number of api requests per month before 429 is returned. If using an API key, calls over this are charged.
API_BILLING_UNIT: 100, // how many calls is equivalent to a unit of calls e.g. 100 calls per $0.01.
API_KEY_PER_MIN_LIMIT: 300, // Rate limit per minute if using an API key
NO_API_KEY_PER_MIN_LIMIT: 60, // Rate limit per minute if not using an API key
ADMIN_ACCOUNT_IDS: "", // Whitelisted, comma separated account IDs to access /admin* routes
ADMIN_ACCOUNT_IDS: '', // Whitelisted, comma separated account IDs to access /admin* routes
BACKUP_RETRIEVER_PERCENT: 0, // percent of replay salts to fetch from backup data source
GCDATA_PARALLELISM: 1, // Number of simultaneous GC match details requests to make (per retriever)
STRIPE_SECRET: "rk_test_gRqwhv4xqv0a1olp8kk8fZ94", // for stripe payment processing (kept on server)
STRIPE_API_PLAN: "plan_CgLthOgwrDgz2K", // plan id for stripe metering
STRIPE_SECRET: 'rk_test_gRqwhv4xqv0a1olp8kk8fZ94', // for stripe payment processing (kept on server)
STRIPE_API_PLAN: 'plan_CgLthOgwrDgz2K', // plan id for stripe metering
ES_SEARCH_PERCENT: 0, // % of users to roll out elasticsearch to
MATCH_ARCHIVE_S3_KEY_ID: '', // S3-compatible key ID to archive parsed match blobs
MATCH_ARCHIVE_S3_KEY_SECRET: '', // S3-compatible key secret to archive parsed match blobs
Expand All @@ -82,16 +82,16 @@ const defaults = {
Object.keys(defaults).forEach((key) => {
process.env[key] = key in process.env ? process.env[key] : defaults[key];
});
if (process.env.NODE_ENV === "development") {
if (process.env.NODE_ENV === 'development') {
// force PORT to null in development so we can run multiple web services without conflict
process.env.PORT = "";
process.env.PORT = '';
}
if (process.env.NODE_ENV === "test") {
process.env.PORT = ""; // use service defaults
if (process.env.NODE_ENV === 'test') {
process.env.PORT = ''; // use service defaults
process.env.POSTGRES_URL = process.env.POSTGRES_TEST_URL;
process.env.CASSANDRA_URL = process.env.CASSANDRA_TEST_URL;
process.env.REDIS_URL = process.env.REDIS_TEST_URL;
process.env.SESSION_SECRET = "testsecretvalue";
process.env.SESSION_SECRET = 'testsecretvalue';
process.env.ENABLE_MATCH_CACHE = 1;
process.env.FRONTEND_PORT = 5001;
process.env.PARSER_PORT = 5201;
Expand Down
8 changes: 4 additions & 4 deletions dev/accountHelper.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const input = "[email protected]";
const arr = input.split("@");
const input = '[email protected]';
const arr = input.split('@');
const user = arr[0];
let count = 0;
const limit = 5000;

function permute(user, n) {
if (n >= user.length || (limit && count > limit)) {
arr[0] = user;
console.log(arr.join("@"));
console.log(arr.join('@'));
count += 1;
return;
}
const diff = [user.substr(0, n), user.substr(n)].join(".");
const diff = [user.substr(0, n), user.substr(n)].join('.');
// don't add a period
permute(user, n + 1);
// add a period
Expand Down
7 changes: 3 additions & 4 deletions dev/archiveTest.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { archivePut, archiveGet } from "../store/archive.js";
import { getMatchData, getPlayerMatchData } from "../store/queries.js";
import { archivePut, archiveGet } from '../store/archive.js';
import { getMatchData, getPlayerMatchData } from '../store/queries.js';

// Read some match data
const match = await getMatchData(7465883253);
const players = await getPlayerMatchData(7465883253);
const blob = Buffer.from(JSON.stringify({...match, players }));
const blob = Buffer.from(JSON.stringify({ ...match, players }));

// Archive it
await archivePut(match.match_id.toString(), blob);
Expand All @@ -15,4 +15,3 @@ const readBack = await archiveGet(match.match_id.toString());
console.log(blob.length, readBack.length);

// Confirm API returns the same data whether we used the archive or not

18 changes: 9 additions & 9 deletions dev/checkAccounts.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs';
import Steam from 'steam';
import async from 'async';
const accountData = fs.readFileSync("./STEAM_ACCOUNT_DATA_BAD.txt", "utf8");
const accountArray = accountData.split(require("os").EOL);
const accountData = fs.readFileSync('./STEAM_ACCOUNT_DATA_BAD.txt', 'utf8');
const accountArray = accountData.split(require('os').EOL);

let index = Number(process.argv[2]) || -1;
async.whilst(
Expand All @@ -11,25 +11,25 @@ async.whilst(
index += 1;
const random = index;
// const random = Math.floor(Math.random() * accountArray.length);
const user = accountArray[random].split("\t")[0];
const pass = accountArray[random].split("\t")[1];
const user = accountArray[random].split('\t')[0];
const pass = accountArray[random].split('\t')[1];
const logOnDetails = {
account_name: user,
password: pass,
};
const client = new Steam.SteamClient();
client.steamUser = new Steam.SteamUser(client);
client.connect();
client.on("connected", () => {
client.on('connected', () => {
client.steamUser.logOn(logOnDetails);
});
client.on("logOnResponse", (logOnResp) => {
client.on('logOnResponse', (logOnResp) => {
if (logOnResp.eresult === Steam.EResult.AccountDisabled) {
console.error(index, user, "failed", logOnResp.eresult);
console.error(index, user, 'failed', logOnResp.eresult);
} else if (logOnResp.eresult === Steam.EResult.InvalidPassword) {
console.error(index, user, "failed", logOnResp.eresult);
console.error(index, user, 'failed', logOnResp.eresult);
} else {
console.error(index, user, "passed", logOnResp.eresult);
console.error(index, user, 'passed', logOnResp.eresult);
}
client.disconnect();
setTimeout(cb, 500);
Expand Down
4 changes: 2 additions & 2 deletions dev/createAccounts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ async.eachSeries(
Array.from(new Array(1000), (v, i) => i),
(i, cb) => {
steam.logOn(() => {});
steam.once("loggedOn", () => {
steam.once('loggedOn', () => {
const name = `${time}_${i}`;
const password = (Math.random() + 1).toString(36).substring(7);
const email = `${name}@email.com`;
steam.createAccount(name, password, email, (result, steamid) => {
console.error(name, password, result, steamid);
if (result === Steam.EResult.OK) {
console.log("%s\t%s", name, password);
console.log('%s\t%s', name, password);
}
steam.logOff(() => {});
setTimeout(cb, 61000);
Expand Down
16 changes: 8 additions & 8 deletions dev/findProMatches.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import async from 'async';
import queries from '../store/queries.js';
import db from '../store/db.js';
import { generateJob, getData } from '../util/utility.js';
import { generateJob, getData } from '../util/utility.js';

// const leagueUrl = generateJob('api_leagues', {}).url;

Expand All @@ -19,7 +19,7 @@ function getPage(url, leagueid, cb) {
data.result.matches,
(match, cb) => {
console.log(match.match_id);
const job = generateJob("api_details", {
const job = generateJob('api_details', {
match_id: match.match_id,
});
const { url } = job;
Expand Down Expand Up @@ -51,7 +51,7 @@ function getPage(url, leagueid, cb) {
throw err;
}
if (data.result.results_remaining) {
const url2 = generateJob("api_history", {
const url2 = generateJob('api_history', {
leagueid,
start_at_match_id:
data.result.matches[data.result.matches.length - 1].match_id - 1,
Expand All @@ -66,10 +66,10 @@ function getPage(url, leagueid, cb) {
}

// From DB
db.select("leagueid")
.from("leagues")
.where("tier", "professional")
.orWhere("tier", "premium")
db.select('leagueid')
.from('leagues')
.where('tier', 'professional')
.orWhere('tier', 'premium')
.asCallback((err, data) => {
if (err) {
throw err;
Expand All @@ -78,7 +78,7 @@ db.select("leagueid")
async.eachSeries(
leagueIds,
(leagueid, cb) => {
const { url } = generateJob("api_history", {
const { url } = generateJob('api_history', {
leagueid,
});
return getPage(url, leagueid, cb);
Expand Down
6 changes: 3 additions & 3 deletions dev/generateFakeRatings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ function randByCentralLimitTheorem() {
function gaussianRandom(mean, std) {
if (mean === undefined || std === undefined) {
throw new Error(
"Gaussian random needs 2 arguments (mean, standard deviation)"
'Gaussian random needs 2 arguments (mean, standard deviation)'
);
}
return randByCentralLimitTheorem() * std + mean;
}

db.from("players").asCallback((err, players) => {
db.from('players').asCallback((err, players) => {
async.each(
players,
(p, cb) => {
Expand All @@ -30,7 +30,7 @@ db.from("players").asCallback((err, players) => {
time: new Date(),
};
console.log(fake.account_id, fake.solo_competitive_rank);
db.insert(fake).into("player_ratings").asCallback(cb);
db.insert(fake).into('player_ratings').asCallback(cb);
},
(err) => {
process.exit(Number(err));
Expand Down
4 changes: 2 additions & 2 deletions dev/keyTest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import config from '../config.js';
const output = [];

async.eachSeries(
config.STEAM_API_KEY.split(","),
config.STEAM_API_KEY.split(','),
(key, cb) => {
setTimeout(() => {
request(
Expand All @@ -23,6 +23,6 @@ async.eachSeries(
}, 1000);
},
() => {
console.log(output.join(","));
console.log(output.join(','));
}
);
12 changes: 6 additions & 6 deletions dev/loginTest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ const logOnDetails = {
password: pass,
};
client.Dota2 = new Dota2.Dota2Client(client, false, false);
client.Dota2.on("ready", () => {
console.log("dota ready");
client.Dota2.on('ready', () => {
console.log('dota ready');
});
client.steamUser = new Steam.SteamUser(client);
client.connect();
client.on("connected", () => {
console.log("[STEAM] Trying to log on with %s,%s", user, pass);
client.on('connected', () => {
console.log('[STEAM] Trying to log on with %s,%s', user, pass);
client.steamUser.logOn(logOnDetails);
});
client.on("logOnResponse", (logOnResp) => {
client.on('logOnResponse', (logOnResp) => {
if (logOnResp.eresult !== Steam.EResult.OK) {
// try logging on again
console.error(logOnResp);
client.steamUser.logOn(logOnDetails);
return;
}
if (client && client.steamID) {
console.log("[STEAM] Logged on %s", client.steamID);
console.log('[STEAM] Logged on %s', client.steamID);
client.Dota2.launch();
}
});
4 changes: 2 additions & 2 deletions dev/metaParse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ files.forEach((file) => {
});
*/

const builder = ProtoBuf.loadProtoFile("./proto/dota_match_metadata.proto");
const builder = ProtoBuf.loadProtoFile('./proto/dota_match_metadata.proto');
const Message = builder.build();
const buf = fs.readFileSync("./2750586075_1028519576.meta");
const buf = fs.readFileSync('./2750586075_1028519576.meta');
const message = Message.CDOTAMatchMetadataFile.decode(buf);
message.metadata.teams.forEach((team) => {
team.players.forEach((player) => {
Expand Down
Loading

0 comments on commit a1d40ea

Please sign in to comment.