Skip to content

Commit

Permalink
a few more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Feb 21, 2024
1 parent 153b2ee commit 861a130
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/api/client.ts
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/types/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/types/queryParameter.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -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());
Expand Down
2 changes: 0 additions & 2 deletions src/types/requestPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -43,7 +42,6 @@ export interface ExecuteQueryPayload {
performance: string;
}


/// Payload sent with query update requests.
export interface UpdateQueryPayload {
name?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/types/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 861a130

Please sign in to comment.