<commit_before>import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';

import { Observable } from 'rxjs/Observable';

import * as fromRoot from '../reducers';

import * as queryActions from '../actions/query/query';
import * as gqlSchemaActions from '../actions/gql-schema/gql-schema';

import { DbService } from '../services/db.service';

@Injectable()
export class QueryService {

  constructor(
    private db: DbService,
    private store: Store<fromRoot.State>
  ) { }

  loadUrl(windowId): Observable<any> {
    return this.db.getItem(`${windowId}:url`).subscribe(url => {
      if (url) {
        this.store.dispatch(new queryActions.SetUrlFromDbAction(url, windowId));
      }
    });
  }

  loadQuery(windowId): Observable<any> {
    return this.db.getItem(`${windowId}:query`).subscribe(query => {
      if (query) {
        this.store.dispatch(new queryActions.SetQueryFromDbAction(query, windowId));
      }
    });
  }

  loadIntrospection(windowId): Observable<any> {
    return this.db.getItem(`${windowId}:introspection`).subscribe(introspectionData => {
      if (introspectionData) {<commit_msg>Fixed bug in query service.<commit_after>import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';

import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';

import * as fromRoot from '../reducers';

import * as queryActions from '../actions/query/query';
import * as gqlSchemaActions from '../actions/gql-schema/gql-schema';

import { DbService } from '../services/db.service';

@Injectable()
export class QueryService {

  constructor(
    private db: DbService,
    private store: Store<fromRoot.State>
  ) { }

  loadUrl(windowId): Subscription {
    return this.db.getItem(`${windowId}:url`).subscribe(url => {
      if (url) {
        this.store.dispatch(new queryActions.SetUrlFromDbAction(url, windowId));
      }
    });
  }

  loadQuery(windowId): Subscription {
    return this.db.getItem(`${windowId}:query`).subscribe(query => {
      if (query) {
        this.store.dispatch(new queryActions.SetQueryFromDbAction(query, windowId));
      }
    });
  }

  loadIntrospection(windowId): Subscription {
    return this.db.getItem(`${windowId}:introspection`).subscribe(introspectionData => {
      if (introspectionData) {
{'fraction_non_alphanumeric': 0.1495927989712816, 'fraction_numerical': 0.0, 'mean_word_length': 3.8523908523908523, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4131569', 'n_tokens_mistral': 722, 'n_tokens_neox': 718, 'n_words': 140}