From 861a1305b2aa93cdd7505dce97f5c926c3f2ae43 Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Wed, 21 Feb 2024 09:59:14 +0100 Subject: [PATCH] a few more comments --- src/api/client.ts | 4 +--- src/types/query.ts | 2 +- src/types/queryParameter.ts | 4 +--- src/types/requestPayload.ts | 2 -- src/types/response.ts | 2 +- src/utils.ts | 10 ++++++++++ 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/api/client.ts b/src/api/client.ts index 9214203..affe937 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -1,5 +1,5 @@ /** - * This is the common entry point for end users. + * This is the common entry point for end users. * A class with exhibits all Dune API properties and extensions. * Specifically, this class is a composition of QueryAPI, ExecutionAPI * and also contains implementations of runQuery[CSV], getLatestResults[CSV] @@ -19,8 +19,6 @@ import { POLL_FREQUENCY_SECONDS, THREE_MONTHS_IN_HOURS } from "../constants"; import { ExecutionParams } from "../types/requestPayload"; import { QueryAPI } from "./query"; - -/// const TERMINAL_STATES = [ ExecutionState.CANCELLED, ExecutionState.COMPLETED, diff --git a/src/types/query.ts b/src/types/query.ts index 97b59a4..e0dd093 100644 --- a/src/types/query.ts +++ b/src/types/query.ts @@ -26,7 +26,7 @@ export interface DuneQuery { query_sql: string; /// whether or not the query is private. is_private: boolean; - /// whether or not the query is archived. + /// whether or not the query is archived. /// Note: This is as close as a user can get to deleting a query. is_archived: boolean; /// whether or not the query is unsaved. diff --git a/src/types/queryParameter.ts b/src/types/queryParameter.ts index e6cc4d3..9918733 100644 --- a/src/types/queryParameter.ts +++ b/src/types/queryParameter.ts @@ -1,4 +1,3 @@ - /// All supported Dune Query Parameter types. export enum ParameterType { /// Note that text fields may also be used for varbinary data types. @@ -8,7 +7,6 @@ export enum ParameterType { ENUM = "enum", } - /// Class representing Dune Query Parameters with convience constructor methods for each type. export class QueryParameter { type: ParameterType; @@ -25,7 +23,7 @@ export class QueryParameter { static text(name: string, value: string): QueryParameter { return new QueryParameter(ParameterType.TEXT, name, value); } - + /// Number type parameter constructor static number(name: string, value: string | number): QueryParameter { return new QueryParameter(ParameterType.NUMBER, name, value.toString()); diff --git a/src/types/requestPayload.ts b/src/types/requestPayload.ts index c8484cb..a177fc2 100644 --- a/src/types/requestPayload.ts +++ b/src/types/requestPayload.ts @@ -18,7 +18,6 @@ export type RequestPayload = | UpdateQueryPayload | CreateQueryPayload; - /// Utility method used by router to parse request payloads. export function payloadJSON(payload?: RequestPayload): string { if (payload !== undefined) { @@ -43,7 +42,6 @@ export interface ExecuteQueryPayload { performance: string; } - /// Payload sent with query update requests. export interface UpdateQueryPayload { name?: string; diff --git a/src/types/response.ts b/src/types/response.ts index 6860401..8442d8c 100644 --- a/src/types/response.ts +++ b/src/types/response.ts @@ -5,7 +5,7 @@ export enum ExecutionState { PENDING = "QUERY_STATE_PENDING", CANCELLED = "QUERY_STATE_CANCELLED", FAILED = "QUERY_STATE_FAILED", - EXPIRED = "QUERY_STATE_EXPIRED" + EXPIRED = "QUERY_STATE_EXPIRED", } /// Response resturned from query execution request. diff --git a/src/utils.ts b/src/utils.ts index 5c0065a..5d15420 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,9 +1,19 @@ export const logPrefix = "dune-client:"; +/** + * utility sleep method. + * @param seconds number of seconds to sleep for. + * @returns void + */ export function sleep(seconds: number) { return new Promise((resolve) => setTimeout(resolve, seconds * 1000)); } +/** + * Computes the difference between a given timestamp and now (in hours) + * @param timestamp + * @returns time difference between input `timestamp` and now (in hours) + */ export function ageInHours(timestamp: Date | string): number { // Get the current date and time const now: Date = new Date();