diff options
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/color-service.ts | 2 | ||||
-rw-r--r-- | app/services/help-service.ts | 28 | ||||
-rw-r--r-- | app/services/plan-service.ts | 22 | ||||
-rw-r--r-- | app/services/syntax-highlight-service.ts | 11 |
4 files changed, 33 insertions, 30 deletions
diff --git a/app/services/color-service.ts b/app/services/color-service.ts index 37183c0..3116a07 100644 --- a/app/services/color-service.ts +++ b/app/services/color-service.ts @@ -15,7 +15,7 @@ export class ColorService { hslToRgb(h, s, l) { var r, g, b; - if (s == 0) { + if (s === 0) { r = g = b = l; // achromatic } else { function hue2rgb(p, q, t) { diff --git a/app/services/help-service.ts b/app/services/help-service.ts index 0195aff..6067b05 100644 --- a/app/services/help-service.ts +++ b/app/services/help-service.ts @@ -7,24 +7,24 @@ export class HelpService { } export var NODE_DESCRIPTIONS = { - "LIMIT":"returns a specified number of rows from a record set.", - "SORT": "sorts a record set based on the specified sort key.", - "NESTED LOOP": `merges two record sets by looping through every record in the first set and + 'LIMIT':'returns a specified number of rows from a record set.', + 'SORT': 'sorts a record set based on the specified sort key.', + 'NESTED LOOP': `merges two record sets by looping through every record in the first set and trying to find a match in the second set. All matching records are returned.`, - "MERGE JOIN": `merges two record sets by first sorting them on a <strong>join key</strong>.`, - "HASH": `generates a hash table from the records in the input recordset. Hash is used by + 'MERGE JOIN': `merges two record sets by first sorting them on a <strong>join key</strong>.`, + 'HASH': `generates a hash table from the records in the input recordset. Hash is used by <strong>Hash Join</strong>.`, - "HASH JOIN": `joins to record sets by hashing one of them (using a <strong>Hash Scan</scan>).`, - "AGGREGATE": `groups records together based on a GROUP BY or aggregate function (like <code>sum()</code>).`, - "HASHAGGREGATE": `groups records together based on a GROUP BY or aggregate function (like sum()). Hash Aggregate uses + 'HASH JOIN': `joins to record sets by hashing one of them (using a <strong>Hash Scan</scan>).`, + 'AGGREGATE': `groups records together based on a GROUP BY or aggregate function (like <code>sum()</code>).`, + 'HASHAGGREGATE': `groups records together based on a GROUP BY or aggregate function (like sum()). Hash Aggregate uses a hash to first organize the records by a key.`, - "SEQ SCAN": `finds relevant records by sequentially scanning the input record set. When reading from a table, + 'SEQ SCAN': `finds relevant records by sequentially scanning the input record set. When reading from a table, Seq Scans (unlike Index Scans) perform a single read operation (only the table is read).`, - "INDEX SCAN": `finds relevant records based on an <strong>Index</strong>. Index Scans perform 2 read operations: one to + 'INDEX SCAN': `finds relevant records based on an <strong>Index</strong>. Index Scans perform 2 read operations: one to read the index and another to read the actual value from the table.`, - "INDEX ONLY SCAN": `finds relevant records based on an <strong>Index</strong>. Index Only Scans perform a single read operation + 'INDEX ONLY SCAN': `finds relevant records based on an <strong>Index</strong>. Index Only Scans perform a single read operation from the index and do not read from the corresponding table.`, - "BITMAP HEAP SCAN": "searches through the pages returned by the <strong>Bitmap Index Scan</strong> for relevant rows.", - "BITMAP INDEX SCAN": `uses a <strong>Bitmap Index</strong> (index which uses 1 bit per page) to find all relevant pages. + 'BITMAP HEAP SCAN': 'searches through the pages returned by the <strong>Bitmap Index Scan</strong> for relevant rows.', + 'BITMAP INDEX SCAN': `uses a <strong>Bitmap Index</strong> (index which uses 1 bit per page) to find all relevant pages. Results of this node are fed to the <strong>Bitmap Heap Scan</strong>.` -} +}; diff --git a/app/services/plan-service.ts b/app/services/plan-service.ts index bf74c38..b5f8102 100644 --- a/app/services/plan-service.ts +++ b/app/services/plan-service.ts @@ -1,5 +1,5 @@ import {IPlan} from '../interfaces/iplan'; -import {HighlightType, EstimateDirection} from '../enums'; +import {EstimateDirection} from '../enums'; /// <reference path="moment.d.ts" /> /// <reference path="lodash.d.ts" /> @@ -22,11 +22,11 @@ export class PlanService { HASH_CONDITION_PROP: string = 'Hash Cond'; // computed by pev - COMPUTED_TAGS_PROP: string = "*Tags"; + COMPUTED_TAGS_PROP: string = '*Tags'; - COSTLIEST_NODE_PROP: string = "*Costiest Node (by cost)"; - LARGEST_NODE_PROP: string = "*Largest Node (by rows)"; - SLOWEST_NODE_PROP: string = "*Slowest Node (by duration)"; + COSTLIEST_NODE_PROP: string = '*Costiest Node (by cost)'; + LARGEST_NODE_PROP: string = '*Largest Node (by rows)'; + SLOWEST_NODE_PROP: string = '*Slowest Node (by duration)'; MAXIMUM_COSTS_PROP: string = '*Most Expensive Node (cost)'; MAXIMUM_ROWS_PROP: string = '*Largest Node (rows)'; @@ -38,6 +38,8 @@ export class PlanService { ARRAY_INDEX_KEY: string = 'arrayIndex'; + PEV_PLAN_TAG: string = 'plan_'; + private _maxRows: number = 0; private _maxCost: number = 0; private _maxDuration: number = 0; @@ -46,7 +48,9 @@ export class PlanService { var plans: Array<IPlan> = []; for (var i in localStorage) { - plans.push(JSON.parse(localStorage[i])); + if (_.startsWith(i, this.PEV_PLAN_TAG)) { + plans.push(JSON.parse(localStorage[i])); + } } return plans; @@ -58,7 +62,7 @@ export class PlanService { createPlan(planName: string, planContent: string, planQuery): IPlan { var plan: IPlan = { - id: 'plan_' + new Date().getTime().toString(), + id: this.PEV_PLAN_TAG + new Date().getTime().toString(), name: planName || 'plan created on ' + moment().format('LLL'), createdOn: new Date(), content: JSON.parse(planContent)[0], @@ -99,7 +103,7 @@ export class PlanService { if (key === this.PLANS_PROP) { _.each(value, (value) => { this.processNode(value); - }) + }); } }); } @@ -136,7 +140,7 @@ export class PlanService { if (key === this.PLANS_PROP) { _.each(value, (value) => { this.findOutlierNodes(value); - }) + }); } }); } diff --git a/app/services/syntax-highlight-service.ts b/app/services/syntax-highlight-service.ts index 17f6e61..93ccb99 100644 --- a/app/services/syntax-highlight-service.ts +++ b/app/services/syntax-highlight-service.ts @@ -7,9 +7,8 @@ export class SyntaxHighlightService { highlight(code: string, keyItems: Array<string>) { hljs.registerLanguage('sql', LANG_SQL); - hljs.configure({ - tabReplace: ' ', // 4 spaces + tabReplace: ' ' }); // prior to syntax highlighting, we want to tag key items in the raw code. making the @@ -17,12 +16,12 @@ export class SyntaxHighlightService { // makes it simpler to find the items we're looing for var result: string = code.toUpperCase().replace(', ', ','); _.each(keyItems, (keyItem: string) => { - result = result.replace(keyItem.toUpperCase(), `${this.OPEN_TAG}${keyItem}${this.CLOSE_TAG}`) + result = result.replace(keyItem.toUpperCase(), `${this.OPEN_TAG}${keyItem}${this.CLOSE_TAG}`); }); result = hljs.highlightAuto(result).value; - result = result.replace(new RegExp(this.OPEN_TAG, 'g'), "<span class='code-key-item'>") - result = result.replace(new RegExp(this.CLOSE_TAG, 'g'), "</span>"); + result = result.replace(new RegExp(this.OPEN_TAG, 'g'), `<span class='code-key-item'>`); + result = result.replace(new RegExp(this.CLOSE_TAG, 'g'), '</span>'); return result; } @@ -185,4 +184,4 @@ export var LANG_SQL = function(hljs) { COMMENT_MODE ] }; -} +}; |