<commit_before>import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Events } from 'ionic-angular';
import { StorageProvider } from './storage.provider';
import { UtilityProvider } from './utility.provider';
import { Migration } from '../model/migration.model';
import { MemoryProvider } from '../memory-provider.model';
import { File } from '@ionic-native/file';
import { FileChooser } from '@ionic-native/file-chooser';
import { InterfaceProvider } from './interface.provider';

@Injectable()
export class MigrationProvider extends MemoryProvider<Migration>{
  private _migrations: string[] = [
    "2.0.0",
  ];

  constructor(
    _events: Events,
    _utility: UtilityProvider,
    _storage: StorageProvider,
    private _http: HttpClient,
    private _file: File,
    private _fileChooser: FileChooser,
    private _interface: InterfaceProvider,
  ) {
    super(
      _events,
      _utility,
      Migration,
      _storage,
      "inventoryApp_migrations",
      "Migration",
    );
  }

  getByVersion(version: string) {
    return this.find(migration => migration.version === version);
  }

  load() {
    return Promise.resolve().then(() => {
      return this.hasDataV1ToExport();
    }).then(hasDataV1ToExport => {
      if (hasDataV1ToExport)
        return this._interface.showAlert({
          title: "Backup",
          message: "BackupMessage"
        }).then(() => {
          return this.exportDataV1();
        }).then(() => {
          return this.clear();
        });
      else
        return Promise.resolve();
    }).then(() => {
      return super.load();
    }).then(() => {
      let migrations = this._migrations.map(migration => this._applyMigration(migration));<commit_msg>Fix migrazioni in debug<commit_after>import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Events } from 'ionic-angular';
import { StorageProvider } from './storage.provider';
import { UtilityProvider } from './utility.provider';
import { Migration } from '../model/migration.model';
import { MemoryProvider } from '../memory-provider.model';
import { File } from '@ionic-native/file';
import { FileChooser } from '@ionic-native/file-chooser';
import { InterfaceProvider } from './interface.provider';

@Injectable()
export class MigrationProvider extends MemoryProvider<Migration>{
  private _migrations: string[] = [
    "2.0.0",
  ];

  constructor(
    _events: Events,
    _utility: UtilityProvider,
    _storage: StorageProvider,
    private _http: HttpClient,
    private _file: File,
    private _fileChooser: FileChooser,
    private _interface: InterfaceProvider,
  ) {
    super(
      _events,
      _utility,
      Migration,
      _storage,
      "inventoryApp_migrations",
      "Migration",
    );

    this._testItems = [
      {
        version: "2.0.0",
        isComplete: true,
        dateCompleted: new Date(),
      }
    ]
  }

  getByVersion(version: string) {
    return this.find(migration => migration.version === version);
  }

  load() {
    return Promise.resolve().then(() => {
      if (this._utility.manifest.isDebug)
        return this._storage.set("inventoryApp_exportDatav1", true);
      else
        return Promise.resolve();
    }).then(() => {
      return this.hasDataV1ToExport();
    }).then(hasDataV1ToExport => {
      if (hasDataV1ToExport)
        return this._interface.showAlert({
          title: "Backup",
          message: "BackupMessage"
        }).then(() => {
          return this.exportDataV1();
        }).then(() => {
          return this.clear();
        });
      else
        return Promise.resolve();
    }).then(() => {
      return super.load();
    }).then(() => {
      let migrations = this._migrations.map(migration => this._applyMigration(migration));
{'fraction_non_alphanumeric': 0.1430062630480167, 'fraction_numerical': 0.004697286012526096, 'mean_word_length': 2.899287894201424, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '1207464', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1103, 'n_words': 245}