Skip to content
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
22,794 changes: 22,427 additions & 367 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
"@babel/plugin-transform-runtime": "^7.11.0",
"@babel/preset-typescript": "^7.10.1",
"@parcel/transformer-typescript-types": "^2.0.1",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.13",
"@types/pouchdb": "^6.4.0",
Expand Down
6 changes: 3 additions & 3 deletions src/TimerDB.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventName, StoredAttempt, Attempt } from "./data/Attempt";
import { PouchDBStorage } from "./storage/PouchDBStorage";
import { Session, SessionCreationOptions } from "./session";
import { Session, SessionCreationOptions } from "./Session";
import { Storage } from "./storage/Storage";

export class TimerDB {
Expand All @@ -9,8 +9,8 @@ export class TimerDB {
this.storage = new PouchDBStorage();
}

startSync(params: { username: string; password: string }): void {
this.storage.connectRemoteDB(params.username, params.password);
startSync(params: { username: string; password: string, options?: { dbURL: string } }): void {
this.storage.connectRemoteDB(params.username, params.password, params.options);
}

// TODO: provide a way to get only sessions with solves.
Expand Down
3 changes: 3 additions & 0 deletions src/data/Attempt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ type PenaltyReason =

// TODO: `during-solve`?
type PenaltyWhen = "pre-solve" | "post-solve";
type PenaltyFailure = "DNF" | "DNS";

export interface Penalty {
// Number of milliseconds that the penalty added to the result.
// TODO: Represent DNF penalty. (And maybe DNS?)
ms?: number;
reason?: PenaltyReason;
// represents if the penalty was a failure (DNF or DNS). Null means no failure
resultFailure?: PenaltyFailure;
// If `when` is not set, the default meaning is `post-solve`.
when?: PenaltyWhen;
}
2 changes: 1 addition & 1 deletion src/storage/AttemptCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { StoredAttempt } from "../data/Attempt";
import { PouchDBStorage } from "./PouchDBStorage";
import { AttemptUUID, SessionUUID } from "../UUID";
import { Storage } from "./storage";
import { Storage } from "./Storage";

const MIN_SIZE_CAP = 1000;
const MAX_SIZE_CAP = 1050;
Expand Down
7 changes: 4 additions & 3 deletions src/storage/PouchDBStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
isValidStoredSessionMetadata,
isValidSessionMetadata,
} from "../data/validate";
import { SyncChangeListener } from "./storage";
import { SyncChangeListener } from "./Storage";

PouchDB.plugin(PouchDBFind);

Expand All @@ -37,8 +37,9 @@ export class PouchDBStorage {
// });
}

connectRemoteDB(username: string, password: string): void {
const url = new URL(DB_URL);
connectRemoteDB(username: string, password: string, options?: {dbURL: string}): void {
var tempURL = !(options === undefined) ? options.dbURL : DB_URL;
const url = new URL(tempURL);
url.username = username;
url.password = password;
url.pathname = `results-${localStorage.timerDBUsername}`;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SessionUUID } from "../UUID";
export type SyncChangeListener = (attempt: StoredAttempt[]) => void;

export declare interface Storage {
connectRemoteDB(username: string, password: string): void;
connectRemoteDB(username: string, password: string, options?: { dbURL: string }): void;

// Sessions
createSession(
Expand Down