{"action":"created","comment":{"url":"https://api.github.com/repos/coveo/search-ui/pulls/comments/177840697","pull_request_review_id":107789348,"id":177840697,"diff_hunk":"@@ -0,0 +1,171 @@\n+import { RankingInfoTable } from './RankingInfoTable';\n+import { MetaDataTable } from './MetaDataTable';\n+import { IComponentBindings } from '../Base/ComponentBindings';\n+import { IAttributeChangedEventArg } from '../../models/Model';\n+import { $$ } from '../../utils/Dom';\n+import { ModalBox } from '../../ExternalModulesShim';\n+import { QueryStateModel, ResultListEvents, DomUtils, Logger } from '../../Core';\n+import { RelevanceInspectorTabs } from './RelevanceInspectorTabs';\n+import 'styling/_RelevanceInspector';\n+import { ExecutionReport } from './ExecutionReport';\n+import { AvailableFieldsTable } from './AvailableFieldsTable';\n+import agGridModule = require('ag-grid/main');\n+import { debounce } from 'underscore';\n+import { IDisplayedNewResultEventArgs } from '../../events/ResultListEvents';\n+import { InlineRankingInfo } from './InlineRankingInfo';\n+\n+export interface IRelevanceInspectorConstructor {\n+  new (element: HTMLElement, bindings: IComponentBindings): RelevanceInspector;\n+}\n+\n+export interface IRelevanceInspectorTab {\n+  gridOptions: agGridModule.GridOptions;\n+}\n+\n+export class RelevanceInspector {\n+  private opened = false;\n+  private activeTab: string;\n+  private tabs: Record<string, IRelevanceInspectorTab>;\n+  private modalBoxModule = ModalBox;\n+\n+  constructor(public element: HTMLElement, public bindings: IComponentBindings) {\n+    $$(this.element).text('Relevance Inspector');\n+    $$(this.element).addClass('coveo-button coveo-relevance-inspector');\n+    $$(this.bindings.root).on(\n+      this.bindings.queryStateModel.getEventName(QueryStateModel.eventTypes.changeOne + QueryStateModel.attributesEnum.debug),\n+      (e, args: IAttributeChangedEventArg) => this.toggleFromState(args.value)\n+    );\n+    $$(this.element).on('click', () => this.open());\n+    $$(this.bindings.root).on(ResultListEvents.newResultDisplayed, (e, args: IDisplayedNewResultEventArgs) =>\n+      this.handleNewResultDisplayed(args)\n+    );\n+    this.bindings.queryStateModel.get(QueryStateModel.attributesEnum.debug) ? this.show() : this.hide();\n+  }\n+\n+  public get modalBox() {\n+    return this.modalBoxModule;\n+  }\n+\n+  public set modalBox(modalBoxModule) {\n+    this.modalBoxModule = modalBoxModule;\n+  }\n+\n+  public hide() {\n+    $$(this.element).addClass('coveo-hidden');\n+  }\n+\n+  public show() {\n+    $$(this.element).removeClass('coveo-hidden');\n+  }\n+\n+  public async open() {\n+    if (this.opened) {\n+      return;\n+    }\n+    this.opened = true;\n+\n+    const content = $$('div');\n+    const animation = DomUtils.getBasicLoadingAnimation();\n+    content.append(animation);\n+    this.modalBox.open(content.el, this.modalBoxOptions);\n+    const rows = await this.buildTabs();\n+    if (rows) {\n+      animation.remove();\n+      content.append(rows.el);\n+    } else {\n+      this.modalBox.close();\n+    }\n+  }\n+\n+  private handleNewResultDisplayed(args: IDisplayedNewResultEventArgs) {\n+    if (this.bindings.queryStateModel.get(QueryStateModel.attributesEnum.debug)) {\n+      $$(args.item).addClass('coveo-with-inline-ranking-info');\n+      if ($$(args.item).hasClass('coveo-table-layout')) {\n+        $$(args.item).append(new InlineRankingInfo(args.result).build().el);\n+      } else {\n+        $$(args.item).prepend(new InlineRankingInfo(args.result).build().el);\n+      }\n+    }\n+  }\n+\n+  private get modalBoxOptions() {\n+    return {\n+      title: 'Relevance Inspector',\n+      titleClose: false,\n+      overlayClose: true,\n+      sizeMod: 'big',\n+      className: 'relevance-inspector-modal',\n+      validation: () => {\n+        this.opened = false;\n+        return true;\n+      }\n+    };\n+  }\n+\n+  private toggleFromState(stateValue: number) {\n+    stateValue != 0 ? this.show() : this.hide();\n+    this.modalBox.close();\n+  }\n+\n+  private async buildTabs() {\n+    const lastResults = this.bindings.queryController.getLastResults().results;\n+    if (!lastResults || lastResults.length == 0) {\n+      new Logger(this).error(\n+        'Could not open Relevance Inspector because there is no results to display. Please execute a query beforehand',\n+        lastResults\n+      );\n+      return;\n+    }\n+    if (!lastResults[0].rankingInfo) {\n+      new Logger(this).error(\n+        'Could not open Relevance Inspector because there is no ranking info returned on the results. Please execute a query in debug mode beforehad',\n+        lastResults\n+      );\n+      return;\n+    }\n+\n+    const container = $$('div');\n+\n+    const rankingInfoTable = await new RankingInfoTable(lastResults, this.bindings);","path":"src/ui/RelevanceInspector/RelevanceInspector.ts","position":129,"original_position":129,"commit_id":"35dd3d861521d838f5e7872f81222ee22aface2b","original_commit_id":"a9e332b9c0a094dba5c8401e5e8f48f005ccdda0","user":{"login":"dms1lva","id":6422665,"avatar_url":"https://avatars2.githubusercontent.com/u/6422665?v=4","gravatar_id":"","url":"https://api.github.com/users/dms1lva","html_url":"https://github.com/dms1lva","followers_url":"https://api.github.com/users/dms1lva/followers","following_url":"https://api.github.com/users/dms1lva/following{/other_user}","gists_url":"https://api.github.com/users/dms1lva/gists{/gist_id}","starred_url":"https://api.github.com/users/dms1lva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dms1lva/subscriptions","organizations_url":"https://api.github.com/users/dms1lva/orgs","repos_url":"https://api.github.com/users/dms1lva/repos","events_url":"https://api.github.com/users/dms1lva/events{/privacy}","received_events_url":"https://api.github.com/users/dms1lva/received_events","type":"User","site_admin":false},"body":"It's in the spec of the await keyword. Not sure why but using await on a non promise value will return a promise that resolves immediately.","created_at":"2018-03-28T18:06:37Z","updated_at":"2018-03-28T18:06:38Z","html_url":"https://github.com/coveo/search-ui/pull/757#discussion_r177840697","pull_request_url":"https://api.github.com/repos/coveo/search-ui/pulls/757","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/coveo/search-ui/pulls/comments/177840697"},"html":{"href":"https://github.com/coveo/search-ui/pull/757#discussion_r177840697"},"pull_request":{"href":"https://api.github.com/repos/coveo/search-ui/pulls/757"}},"in_reply_to_id":177431099},"pull_request":{"url":"https://api.github.com/repos/coveo/search-ui/pulls/757","id":176612863,"html_url":"https://github.com/coveo/search-ui/pull/757","diff_url":"https://github.com/coveo/search-ui/pull/757.diff","patch_url":"https://github.com/coveo/search-ui/pull/757.patch","issue_url":"https://api.github.com/repos/coveo/search-ui/issues/757","number":757,"state":"open","locked":false,"title":"Relevance Inspector ","user":{"login":"olamothe","id":1591893,"avatar_url":"https://avatars1.githubusercontent.com/u/1591893?v=4","gravatar_id":"","url":"https://api.github.com/users/olamothe","html_url":"https://github.com/olamothe","followers_url":"https://api.github.com/users/olamothe/followers","following_url":"https://api.github.com/users/olamothe/following{/other_user}","gists_url":"https://api.github.com/users/olamothe/gists{/gist_id}","starred_url":"https://api.github.com/users/olamothe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olamothe/subscriptions","organizations_url":"https://api.github.com/users/olamothe/orgs","repos_url":"https://api.github.com/users/olamothe/repos","events_url":"https://api.github.com/users/olamothe/events{/privacy}","received_events_url":"https://api.github.com/users/olamothe/received_events","type":"User","site_admin":false},"body":"This PR adds a new feature to help debug and inspect relevance aspect of Coveo directly from the UI.\r\n\r\nYou can add a #debug=true parameter in the URL, and this set debug mode for the query as well as requesting additional ranking info.\r\n\r\nThis will output inline ranking information in each results, and a \"RelevanceInspector\" button will be appended at the top of the search interface.\r\n\r\nClicking that button will open a modal box which contains various information in a grid format about the results, as well as the query pipeline execution report.\r\n\r\nIt uses https://github.com/ag-grid/ag-grid to build the grid, which has a MIT licence for the free version.\r\n\r\nThe lib is loaded lazily, because it's pretty heavy.\r\n\r\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/pipelines/a3535101-5bbf-4a5b-a909-47fcf8c9f149)","created_at":"2018-03-21T21:19:48Z","updated_at":"2018-03-28T18:06:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c584363ffffbdbbbd655f8d6733859c27df1ed88","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/coveo/search-ui/pulls/757/commits","review_comments_url":"https://api.github.com/repos/coveo/search-ui/pulls/757/comments","review_comment_url":"https://api.github.com/repos/coveo/search-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coveo/search-ui/issues/757/comments","statuses_url":"https://api.github.com/repos/coveo/search-ui/statuses/35dd3d861521d838f5e7872f81222ee22aface2b","head":{"label":"coveo:JSUI-1953","ref":"JSUI-1953","sha":"35dd3d861521d838f5e7872f81222ee22aface2b","user":{"login":"coveo","id":8632328,"avatar_url":"https://avatars2.githubusercontent.com/u/8632328?v=4","gravatar_id":"","url":"https://api.github.com/users/coveo","html_url":"https://github.com/coveo","followers_url":"https://api.github.com/users/coveo/followers","following_url":"https://api.github.com/users/coveo/following{/other_user}","gists_url":"https://api.github.com/users/coveo/gists{/gist_id}","starred_url":"https://api.github.com/users/coveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveo/subscriptions","organizations_url":"https://api.github.com/users/coveo/orgs","repos_url":"https://api.github.com/users/coveo/repos","events_url":"https://api.github.com/users/coveo/events{/privacy}","received_events_url":"https://api.github.com/users/coveo/received_events","type":"Organization","site_admin":false},"repo":{"id":58133471,"name":"search-ui","full_name":"coveo/search-ui","owner":{"login":"coveo","id":8632328,"avatar_url":"https://avatars2.githubusercontent.com/u/8632328?v=4","gravatar_id":"","url":"https://api.github.com/users/coveo","html_url":"https://github.com/coveo","followers_url":"https://api.github.com/users/coveo/followers","following_url":"https://api.github.com/users/coveo/following{/other_user}","gists_url":"https://api.github.com/users/coveo/gists{/gist_id}","starred_url":"https://api.github.com/users/coveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveo/subscriptions","organizations_url":"https://api.github.com/users/coveo/orgs","repos_url":"https://api.github.com/users/coveo/repos","events_url":"https://api.github.com/users/coveo/events{/privacy}","received_events_url":"https://api.github.com/users/coveo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coveo/search-ui","description":"Coveo Search UI framework","fork":false,"url":"https://api.github.com/repos/coveo/search-ui","forks_url":"https://api.github.com/repos/coveo/search-ui/forks","keys_url":"https://api.github.com/repos/coveo/search-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coveo/search-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coveo/search-ui/teams","hooks_url":"https://api.github.com/repos/coveo/search-ui/hooks","issue_events_url":"https://api.github.com/repos/coveo/search-ui/issues/events{/number}","events_url":"https://api.github.com/repos/coveo/search-ui/events","assignees_url":"https://api.github.com/repos/coveo/search-ui/assignees{/user}","branches_url":"https://api.github.com/repos/coveo/search-ui/branches{/branch}","tags_url":"https://api.github.com/repos/coveo/search-ui/tags","blobs_url":"https://api.github.com/repos/coveo/search-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coveo/search-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coveo/search-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/coveo/search-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coveo/search-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/coveo/search-ui/languages","stargazers_url":"https://api.github.com/repos/coveo/search-ui/stargazers","contributors_url":"https://api.github.com/repos/coveo/search-ui/contributors","subscribers_url":"https://api.github.com/repos/coveo/search-ui/subscribers","subscription_url":"https://api.github.com/repos/coveo/search-ui/subscription","commits_url":"https://api.github.com/repos/coveo/search-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/coveo/search-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/coveo/search-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/coveo/search-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/coveo/search-ui/contents/{+path}","compare_url":"https://api.github.com/repos/coveo/search-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coveo/search-ui/merges","archive_url":"https://api.github.com/repos/coveo/search-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coveo/search-ui/downloads","issues_url":"https://api.github.com/repos/coveo/search-ui/issues{/number}","pulls_url":"https://api.github.com/repos/coveo/search-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/coveo/search-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/coveo/search-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coveo/search-ui/labels{/name}","releases_url":"https://api.github.com/repos/coveo/search-ui/releases{/id}","deployments_url":"https://api.github.com/repos/coveo/search-ui/deployments","created_at":"2016-05-05T13:41:09Z","updated_at":"2018-03-28T13:11:43Z","pushed_at":"2018-03-28T13:12:41Z","git_url":"git://github.com/coveo/search-ui.git","ssh_url":"git@github.com:coveo/search-ui.git","clone_url":"https://github.com/coveo/search-ui.git","svn_url":"https://github.com/coveo/search-ui","homepage":null,"size":140438,"stargazers_count":40,"watchers_count":40,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":36,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":36,"open_issues":6,"watchers":40,"default_branch":"master"}},"base":{"label":"coveo:master","ref":"master","sha":"2c04e84126b9a5bed28f3703e4cfe31a1cc59734","user":{"login":"coveo","id":8632328,"avatar_url":"https://avatars2.githubusercontent.com/u/8632328?v=4","gravatar_id":"","url":"https://api.github.com/users/coveo","html_url":"https://github.com/coveo","followers_url":"https://api.github.com/users/coveo/followers","following_url":"https://api.github.com/users/coveo/following{/other_user}","gists_url":"https://api.github.com/users/coveo/gists{/gist_id}","starred_url":"https://api.github.com/users/coveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveo/subscriptions","organizations_url":"https://api.github.com/users/coveo/orgs","repos_url":"https://api.github.com/users/coveo/repos","events_url":"https://api.github.com/users/coveo/events{/privacy}","received_events_url":"https://api.github.com/users/coveo/received_events","type":"Organization","site_admin":false},"repo":{"id":58133471,"name":"search-ui","full_name":"coveo/search-ui","owner":{"login":"coveo","id":8632328,"avatar_url":"https://avatars2.githubusercontent.com/u/8632328?v=4","gravatar_id":"","url":"https://api.github.com/users/coveo","html_url":"https://github.com/coveo","followers_url":"https://api.github.com/users/coveo/followers","following_url":"https://api.github.com/users/coveo/following{/other_user}","gists_url":"https://api.github.com/users/coveo/gists{/gist_id}","starred_url":"https://api.github.com/users/coveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveo/subscriptions","organizations_url":"https://api.github.com/users/coveo/orgs","repos_url":"https://api.github.com/users/coveo/repos","events_url":"https://api.github.com/users/coveo/events{/privacy}","received_events_url":"https://api.github.com/users/coveo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coveo/search-ui","description":"Coveo Search UI framework","fork":false,"url":"https://api.github.com/repos/coveo/search-ui","forks_url":"https://api.github.com/repos/coveo/search-ui/forks","keys_url":"https://api.github.com/repos/coveo/search-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coveo/search-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coveo/search-ui/teams","hooks_url":"https://api.github.com/repos/coveo/search-ui/hooks","issue_events_url":"https://api.github.com/repos/coveo/search-ui/issues/events{/number}","events_url":"https://api.github.com/repos/coveo/search-ui/events","assignees_url":"https://api.github.com/repos/coveo/search-ui/assignees{/user}","branches_url":"https://api.github.com/repos/coveo/search-ui/branches{/branch}","tags_url":"https://api.github.com/repos/coveo/search-ui/tags","blobs_url":"https://api.github.com/repos/coveo/search-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coveo/search-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coveo/search-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/coveo/search-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coveo/search-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/coveo/search-ui/languages","stargazers_url":"https://api.github.com/repos/coveo/search-ui/stargazers","contributors_url":"https://api.github.com/repos/coveo/search-ui/contributors","subscribers_url":"https://api.github.com/repos/coveo/search-ui/subscribers","subscription_url":"https://api.github.com/repos/coveo/search-ui/subscription","commits_url":"https://api.github.com/repos/coveo/search-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/coveo/search-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/coveo/search-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/coveo/search-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/coveo/search-ui/contents/{+path}","compare_url":"https://api.github.com/repos/coveo/search-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coveo/search-ui/merges","archive_url":"https://api.github.com/repos/coveo/search-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coveo/search-ui/downloads","issues_url":"https://api.github.com/repos/coveo/search-ui/issues{/number}","pulls_url":"https://api.github.com/repos/coveo/search-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/coveo/search-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/coveo/search-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coveo/search-ui/labels{/name}","releases_url":"https://api.github.com/repos/coveo/search-ui/releases{/id}","deployments_url":"https://api.github.com/repos/coveo/search-ui/deployments","created_at":"2016-05-05T13:41:09Z","updated_at":"2018-03-28T13:11:43Z","pushed_at":"2018-03-28T13:12:41Z","git_url":"git://github.com/coveo/search-ui.git","ssh_url":"git@github.com:coveo/search-ui.git","clone_url":"https://github.com/coveo/search-ui.git","svn_url":"https://github.com/coveo/search-ui","homepage":null,"size":140438,"stargazers_count":40,"watchers_count":40,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":36,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":36,"open_issues":6,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coveo/search-ui/pulls/757"},"html":{"href":"https://github.com/coveo/search-ui/pull/757"},"issue":{"href":"https://api.github.com/repos/coveo/search-ui/issues/757"},"comments":{"href":"https://api.github.com/repos/coveo/search-ui/issues/757/comments"},"review_comments":{"href":"https://api.github.com/repos/coveo/search-ui/pulls/757/comments"},"review_comment":{"href":"https://api.github.com/repos/coveo/search-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coveo/search-ui/pulls/757/commits"},"statuses":{"href":"https://api.github.com/repos/coveo/search-ui/statuses/35dd3d861521d838f5e7872f81222ee22aface2b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dms1lva"}}