<commit_before>'use strict';

import { Clicker } from '../models/clicker';
import { Click } from '../models/click';
import { Injectable } from 'angular2/core';
import { SqlStorage } from 'ionic-framework/ionic';

@Injectable()
export class Clickers {

  private clickers: Array<Clicker>;
  private ids: Array<String>; // we need to keep a separate reference to ids so we can lookup when the app loads from scratch
  private storage: SqlStorage;

  constructor() {
    this.storage = Clickers.initStorage(); // typeof SqlStorage is not assignable to type StorageEngine seems to be an ionic issue
    this.ids = [];
    this.clickers = [];
    this.initIds()
      .then((ids: Array<String>) => { this.ids = ids; })
      .then(() => this.initClickers(this.ids))
      .then((clickers: Array<Clicker>) => this.clickers = clickers);
  }

  // initialise Ids from SQL storage
  private initIds(): Promise<{}> {
    return new Promise((resolve: Function) => {
      let ids: Array<string> = [];
      this.storage.get('ids') // return the promise so we can chain initClickers
        .then((rawIds: string) => {
          // ids are stored as stringified JSON array
          ids = JSON.parse(String(rawIds)) || [];
        })
        .then(() => resolve(ids));<commit_msg>fixing String vs string type<commit_after>'use strict';

import { Clicker } from '../models/clicker';
import { Click } from '../models/click';
import { Injectable } from 'angular2/core';
import { SqlStorage } from 'ionic-framework/ionic';

@Injectable()
export class Clickers {

  private clickers: Array<Clicker>;
  private ids: Array<string>; // we need to keep a separate reference to ids so we can lookup when the app loads from scratch
  private storage: SqlStorage;

  constructor() {
    this.storage = Clickers.initStorage(); // typeof SqlStorage is not assignable to type StorageEngine seems to be an ionic issue
    this.ids = [];
    this.clickers = [];
    this.initIds()
      .then((ids: Array<string>) => { this.ids = ids; })
      .then(() => this.initClickers(this.ids))
      .then((clickers: Array<Clicker>) => this.clickers = clickers);
  }

  // initialise Ids from SQL storage
  private initIds(): Promise<{}> {
    return new Promise((resolve: Function) => {
      let ids: Array<string> = [];
      this.storage.get('ids') // return the promise so we can chain initClickers
        .then((rawIds: string) => {
          // ids are stored as stringified JSON array
          ids = JSON.parse(rawIds) || [];
        })
        .then(() => resolve(ids));
{'fraction_non_alphanumeric': 0.1423515532835234, 'fraction_numerical': 0.0007864726700747149, 'mean_word_length': 3.109854604200323, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, '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': '5751632', 'n_tokens_mistral': 732, 'n_tokens_neox': 721, 'n_words': 237}