<commit_before>import { Component, OnInit } from '@angular/core';

import { ApiService } from '../shared/api.service';
import { AuthService } from '../shared/auth.service';
import { DBService, Databases } from '../shared/db.service';
import { SessionService } from '../shared/session.service';

import { Paths } from '../shared/paths';

/* Development/Debug component for controlling and testing session & database storage */
@Component({
  selector: 'dev-console',
  templateUrl: './devconsole.component.html',
  styleUrls: ['./devconsole.component.css'],
})
export class DevConsoleComponent {
  constructor(
    private authService: AuthService,
    private apiService: ApiService,
    private sessionService: SessionService,
    private dbService: DBService
  ) {}

  /* Attempts to set lists storage to null, then requests a refresh */
  public async refreshData() {
    if (!this.authService.isLoggedIn()) {
      this.authService.promptLogin();
    } else {
      try { 
        await this.dbService.instance(Databases.Cache).put('lists', {storage: null});
        await this.apiService.getListDirectory();
        this.sessionService.navigate([Paths.SelectDataSource]);
      } catch(error) {
        this.sessionService.displayError(error.message, error);
      }
    }
  }

  /* Delete annotations db */
  public deleteAnnotations(): void {
    this.dbService.instance(Databases.Annotations).destroy();
  }

  /* Delete cache db then redirect to index */
  public async deleteCache() {
    try {
      await this.apiService.purgeCache();
      this.sessionService.reset();
      this.sessionService.navigate([Paths.SelectDataSource]);
    } catch(error) {
      this.sessionService.displayError(error.message, error);
    }<commit_msg>Use new database calls<commit_after>import { Component, OnInit } from '@angular/core';

import { ApiService } from '../shared/api.service';
import { AnnotationService } from '../shared/annotation.service';
import { AuthService } from '../shared/auth.service';
import { SessionService } from '../shared/session.service';

import { Paths } from '../shared/paths';

/* Development/Debug component for controlling and testing session & database storage */
@Component({
  selector: 'dev-console',
  templateUrl: './devconsole.component.html',
  styleUrls: ['./devconsole.component.css'],
})
export class DevConsoleComponent {
  constructor(
    private authService: AuthService,
    private apiService: ApiService,
    private sessionService: SessionService,
    private annotationService: AnnotationService
  ) {}

  /* Attempts to set lists storage to null, then requests a refresh */
  public async refreshData() {
    if (!this.authService.isLoggedIn()) {
      this.authService.promptLogin();
    } else {
      try { 
        await this.apiService.getListDirectory(false, true); // TODO, won't actually store the purged result
        this.sessionService.navigate([Paths.SelectDataSource]);
      } catch(error) {
        this.sessionService.displayError(error.message, error);
      }
    }
  }

  /* Delete annotations db */
  public deleteAnnotations(): void {
    this.annotationService.destroyData();
  }

  /* Delete cache db then redirect to index */
  public async deleteCache() {
    try {
      await this.apiService.purgeCache();
      this.sessionService.reset();
      this.sessionService.navigate([Paths.SelectDataSource]);
    } catch(error) {
      this.sessionService.displayError(error.message, error);
    }
{'fraction_non_alphanumeric': 0.12762892538173437, 'fraction_numerical': 0.0, 'mean_word_length': 3.5564304461942258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4222730', 'n_tokens_mistral': 939, 'n_tokens_neox': 934, 'n_words': 230}