Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@firestone-hs/arena-draft-pick

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firestone-hs/arena-draft-pick - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

dist/misc-utils.d.ts

12

dist/internal-model.d.ts

@@ -0,1 +1,2 @@

import { PickStat } from './model';
export interface InternalArenaMatchStatsDbRow {

@@ -12,2 +13,3 @@ readonly playerClass: string;

readonly runId: string;
readonly playerClass: string;
readonly pickNumber: number;

@@ -17,1 +19,11 @@ readonly options: string;

}
export interface DraftStatsByContextAndPeriod {
readonly lastUpdateDate: string;
readonly context: string;
readonly minWins: number;
readonly cardStats: DraftCardStat[];
readonly dataPoints: number;
}
export interface DraftCardStat extends PickStat {
readonly cardId: string;
}

@@ -8,1 +8,21 @@ export interface DraftPick {

}
export interface DraftStatsByContext {
readonly lastUpdateDate: string;
readonly context: string;
readonly dataPoints: number;
readonly stats: DraftCardCombinedStat[];
}
export interface DraftCardCombinedStat {
readonly cardId: string;
readonly statsByWins: {
[wins: number]: PickStat;
};
readonly statsByWinsGlobal: {
[wins: number]: PickStat;
};
}
export interface PickStat {
offered: number;
picked: number;
}
export type TimePeriod = 'past-20' | 'past-7' | 'past-3' | 'last-patch';

13

dist/save-pick/process-save-arena-draft-pick.js

@@ -23,8 +23,15 @@ "use strict";

INSERT INTO arena_draft_pick
(creationDate, runId, pickNumber, options, pick)
VALUES (?, ?, ?, ?, ?)
(creationDate, playerClass, runId, pickNumber, options, pick)
VALUES (?, ?, ?, ?, ?, ?)
`;
const queryArgs = [new Date(), pick.runId, pick.pickNumber, JSON.stringify(pick.options), pick.pick];
const queryArgs = [
new Date(),
pick.playerClass,
pick.runId,
pick.pickNumber,
JSON.stringify(pick.options),
pick.pick,
];
await mysql.query(query, queryArgs);
};
//# sourceMappingURL=process-save-arena-draft-pick.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const aws_lambda_utils_1 = require("@firestone-hs/aws-lambda-utils");
const config_1 = require("../comon/config");
const db_draft_picks_1 = require("./db-draft-picks");
const db_rows_1 = require("./db-rows");
const draft_stats_1 = require("./draft-stats");
const s3_save_1 = require("./s3-save");
const s3 = new aws_lambda_utils_1.S3();
exports.default = async (event, context) => {

@@ -11,5 +15,12 @@ const cleanup = (0, aws_lambda_utils_1.logBeforeTimeout)(context);

processEndDate.setHours(processEndDate.getHours() + 1);
const hourlyRows = await (0, db_rows_1.loadRows)(processStartDate, processEndDate);
const runsOverDuringLastHour = keepOnlyEndedRuns(hourlyRows);
const pickInfos = await (0, db_draft_picks_1.loadDraftPicks)(runsOverDuringLastHour);
const hourlyRows = await (0, db_rows_1.loadArenaMatches)(processStartDate, processEndDate);
for (const minWin of config_1.MIN_WINS) {
console.log('building stats for min wins', minWin);
const runsOverDuringLastHour = keepOnlyEndedRuns(hourlyRows, minWin);
const pickInfos = await (0, db_draft_picks_1.loadDraftPicks)(runsOverDuringLastHour);
const allRunsStats = (0, draft_stats_1.buildHourlyDraftStats)(pickInfos, minWin);
for (const stat of allRunsStats) {
await (0, s3_save_1.saveDraftStats)(stat, minWin, processStartDate, s3);
}
}
cleanup();

@@ -30,8 +41,11 @@ return { statusCode: 200, body: null };

};
const keepOnlyEndedRuns = (rows) => {
return rows
const keepOnlyEndedRuns = (rows, minWins = 0) => {
const runIds = rows
.filter((row) => row.runId)
.filter((row) => row.wins >= minWins)
.filter((row) => (row.result === 'won' && row.wins === 11) || (row.result === 'lost' && row.losses === 2))
.map((row) => row.runId);
const uniqueRunIds = [...new Set(runIds)];
return uniqueRunIds;
};
//# sourceMappingURL=_buld-hourly-stats.js.map

@@ -43,7 +43,8 @@ "use strict";

const queryStr = `
SELECT playerClass, result, wins, losses, runId
SELECT runId, playerClass, pickNumber, options, pick
FROM arena_draft_pick
WHERE runId in ?
WHERE runId in (?)
ORDER BY runId, pickNumber
`;
console.log('running query', queryStr);
console.log('running query', runIds.length, queryStr);
const query = connection.query(queryStr, [runIds]);

@@ -50,0 +51,0 @@ const rowsToProcess = [];

import { InternalArenaMatchStatsDbRow } from '../../internal-model';
export declare const loadRows: (startDate: Date, endDate: Date) => Promise<readonly InternalArenaMatchStatsDbRow[]>;
export declare const loadArenaMatches: (startDate: Date, endDate: Date) => Promise<readonly InternalArenaMatchStatsDbRow[]>;

@@ -6,6 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.loadRows = void 0;
exports.loadArenaMatches = void 0;
const secretsmanager_1 = __importDefault(require("aws-sdk/clients/secretsmanager"));
const mysql_1 = require("mysql");
const loadRows = async (startDate, endDate) => {
const loadArenaMatches = async (startDate, endDate) => {
const secretRequest = {

@@ -25,3 +25,3 @@ SecretId: 'rds-connection',

};
exports.loadRows = loadRows;
exports.loadArenaMatches = loadArenaMatches;
const performRowProcessIngPool = async (pool, startDate, endDate) => {

@@ -50,3 +50,3 @@ return new Promise((resolve) => {

`;
console.log('running query', queryStr);
console.log('running query', queryStr, [startDate, endDate]);
const query = connection.query(queryStr, [startDate, endDate]);

@@ -53,0 +53,0 @@ const rowsToProcess = [];

{
"name": "@firestone-hs/arena-draft-pick",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc