<commit_before>import { Observable} from 'rxjs';
import { HalDoc } from '../../core';
import { BaseModel } from './base.model';
import { REQUIRED, URL, TOKENY } from './invalid';

export class FeederPodcastModel extends BaseModel {

  // read-only
  id: number;
  previewUrl: string;
  publishedUrl: string;

  // writeable
  SETABLE = ['category', 'subCategory', 'explicit', 'path', 'link', 'newFeedUrl', 'authorName'];
  category: string = '';
  subCategory: string = '';
  explicit: string = '';
  path: string = '';
  link: string = '';
  newFeedUrl: string = '';
  authorName: string = '';

  VALIDATORS = {
    path: [TOKENY('Use letters, numbers and underscores only')],
    link: [REQUIRED(), URL('Not a valid URL')],
    newFeedUrl: [URL('Not a valid URL')]
  };

  constructor(private series: HalDoc, distrib: HalDoc, podcast?: HalDoc, loadRelated = true) {
    super();
    this.init(distrib, podcast, loadRelated);
  }

  key() {
    if (this.doc) {
      return `prx.podcast.${this.doc.id}`;
    } else if (this.series) {
      return `prx.podcast.new.${this.series.id}`; // new in series
    } else {
      return null; // Cannot create podcast until parent series exists
    }
  }

  related() {
    return {};
  }

  decode() {
    this.id = this.doc['id'];
    this.previewUrl = (this.doc.expand('self') || '').replace(/api\/v1\//, '');
    this.publishedUrl = this.doc['publishedUrl'];
    this.explicit = this.doc['explicit'] || '';
    if (this.explicit) {
      this.explicit = this.explicit.charAt(0).toUpperCase() + this.explicit.slice(1);
    }
    this.link = this.doc['link'] || '';
    this.newFeedUrl = this.doc['newFeedUrl'] || '';
    if (this.doc['author']['name']) {
      this.authorName = this.doc['author']['name'];
    } else if (this.series.has('prx:account')) {
      this.series.follow('prx:account').subscribe(account => this.authorName = account['name']);
    } else {
      this.authorName = '';
    }
    // pretend path was blank if it was just the podcast id
    this.path = this.doc['path'] || '';<commit_msg>Fix test<commit_after>import { Observable} from 'rxjs';
import { HalDoc } from '../../core';
import { BaseModel } from './base.model';
import { REQUIRED, URL, TOKENY } from './invalid';

export class FeederPodcastModel extends BaseModel {

  // read-only
  id: number;
  previewUrl: string;
  publishedUrl: string;

  // writeable
  SETABLE = ['category', 'subCategory', 'explicit', 'path', 'link', 'newFeedUrl', 'authorName'];
  category: string = '';
  subCategory: string = '';
  explicit: string = '';
  path: string = '';
  link: string = '';
  newFeedUrl: string = '';
  authorName: string = '';

  VALIDATORS = {
    path: [TOKENY('Use letters, numbers and underscores only')],
    link: [REQUIRED(), URL('Not a valid URL')],
    newFeedUrl: [URL('Not a valid URL')]
  };

  constructor(private series: HalDoc, distrib: HalDoc, podcast?: HalDoc, loadRelated = true) {
    super();
    this.init(distrib, podcast, loadRelated);
  }

  key() {
    if (this.doc) {
      return `prx.podcast.${this.doc.id}`;
    } else if (this.series) {
      return `prx.podcast.new.${this.series.id}`; // new in series
    } else {
      return null; // Cannot create podcast until parent series exists
    }
  }

  related() {
    return {};
  }

  decode() {
    this.id = this.doc['id'];
    this.previewUrl = (this.doc.expand('self') || '').replace(/api\/v1\//, '');
    this.publishedUrl = this.doc['publishedUrl'];
    this.explicit = this.doc['explicit'] || '';
    if (this.explicit) {
      this.explicit = this.explicit.charAt(0).toUpperCase() + this.explicit.slice(1);
    }
    this.link = this.doc['link'] || '';
    this.newFeedUrl = this.doc['newFeedUrl'] || '';
    if (this.doc['author'] && this.doc['author']['name']) {
      this.authorName = this.doc['author']['name'];
    } else if (this.series.has('prx:account')) {
      this.series.follow('prx:account').subscribe(account => this.authorName = account['name']);
    } else {
      this.authorName = '';
    }
    // pretend path was blank if it was just the podcast id
    this.path = this.doc['path'] || '';
{'fraction_non_alphanumeric': 0.18875696631936031, 'fraction_numerical': 0.001453840562151684, 'mean_word_length': 3.1570996978851964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3823390', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1346, 'n_words': 312}