<commit_before>import React from 'react';
import SPELLS from 'common/SPELLS/index';
import Analyzer from 'parser/core/Analyzer';
import ItemHealingDone from 'interface/ItemHealingDone';
import Statistic from 'interface/statistics/Statistic';
import { ApplyBuffEvent, HealEvent, RemoveBuffEvent } from 'parser/core/Events';
import STATISTIC_CATEGORY from 'interface/others/STATISTIC_CATEGORY';
import { ABILITIES_THAT_TRIGGER_ENDURING_RENEWAL } from '../../../constants';
import BoringSpellValueText from 'interface/statistics/components/BoringSpellValueText';
import STATISTIC_ORDER from 'interface/others/STATISTIC_ORDER';

// Example Log: /report/ZtzgPbjw3hRYvJTc/3-Mythic+Taloc+-+Kill+(6:46)/26-萤火兔
class EnduringRenewal extends Analyzer {
  _normalRenewDropoff: any = {};
  _newRenewDropoff: any = {};
  _baseRenewLength = 15;
  healing = 0;
  refreshedRenews = 0;
  secsGained = 0;

  // This module will be tracking the initial application of renews, then recording
  // all renew healing done to those targets after a timestamp + base duration at
  // applybuff since all "refreshbuff" events for renew will be from direct heals
  // (the exception would be benediction renews refreshing but I'm not sure how to
  // counter that and it should be such a small portion of refreshs anyway). Thus,
  // all renew healing after timestamp + baase duraation should be a result of
  // Enduring Renewal

  constructor(options: any) {
    super(options);
    this.active = this.selectedCombatant.hasTalent(SPELLS.ENDURING_RENEWAL_TALENT.id);
  }

  // We do not track "casts" of Renew because casting Renew on an existing target
  // that has renew is also a "direct heal" that triggers Enduring Renewal.
  // It is up for debate whether or not direct heals from Renew should attribute
  // to Enduring Renewal, but for now I will say it does.
  on_byPlayer_applybuff(event: ApplyBuffEvent) {
    this.parseRenew(event); // function incase we decide to disclude manual renew refreshes
  }

  on_byPlayer_removebuff(event: RemoveBuffEvent) {
    const spellId = event.ability.guid;
    if (spellId !== SPELLS.RENEW.id) {
      return;
    }
    delete this._normalRenewDropoff[event.targetID];
    delete this._newRenewDropoff[event.targetID];
  }

  on_byPlayer_heal(event: HealEvent) {
    const spellId = event.ability.guid;
    if (spellId === SPELLS.RENEW.id) {
      if (this._normalRenewDropoff[event.targetID] !== undefined && event.timestamp > this._normalRenewDropoff[event.targetID]) {
        this.healing += event.amount;
      }
    } else if (ABILITIES_THAT_TRIGGER_ENDURING_RENEWAL.includes(spellId)) {
      if (this._newRenewDropoff[event.targetID] !== undefined) {
        const remaining = (this._newRenewDropoff[event.targetID] - event.timestamp) / 1000.0;
        const gain = Math.min((this._baseRenewLength + 6) - remaining, this._baseRenewLength); // be wary of pandemic but also wary of early refreshes
        this._newRenewDropoff[event.targetID] = event.timestamp + (gain * 1000);

        this.refreshedRenews += 1;
        this.secsGained += gain;
      }
    }
  }

  parseRenew(event: ApplyBuffEvent) {
    const spellId = event.ability.guid;
    if (spellId === SPELLS.RENEW.id) {
      this._normalRenewDropoff[event.targetID] = event.timestamp + this._baseRenewLength * 1000;
      this._newRenewDropoff[event.targetID] = event.timestamp + this._baseRenewLength * 1000;
    }
  }

  statistic() {
    return (
      <Statistic
        tooltip={`Refreshed Renews: ${this.refreshedRenews}`}
        size="flexible"
        category={STATISTIC_CATEGORY.TALENTS}
        position={STATISTIC_ORDER.OPTIONAL(1)}
      >
        <BoringSpellValueText spell={SPELLS.ENDURING_RENEWAL_TALENT}>
          <ItemHealingDone amount={this.healing} />
        </BoringSpellValueText>
      </Statistic>
    );
  }
}

export default EnduringRenewal;
<commit_msg>fixing eslint<commit_after>import React from 'react';
import SPELLS from 'common/SPELLS/index';
import Analyzer from 'parser/core/Analyzer';
import ItemHealingDone from 'interface/ItemHealingDone';
import Statistic from 'interface/statistics/Statistic';
import { ApplyBuffEvent, HealEvent, RemoveBuffEvent } from 'parser/core/Events';
import STATISTIC_CATEGORY from 'interface/others/STATISTIC_CATEGORY';
import BoringSpellValueText from 'interface/statistics/components/BoringSpellValueText';
import STATISTIC_ORDER from 'interface/others/STATISTIC_ORDER';
import { ABILITIES_THAT_TRIGGER_ENDURING_RENEWAL } from '../../../constants';

// Example Log: /report/ZtzgPbjw3hRYvJTc/3-Mythic+Taloc+-+Kill+(6:46)/26-萤火兔
class EnduringRenewal extends Analyzer {
  _normalRenewDropoff: any = {};
  _newRenewDropoff: any = {};
  _baseRenewLength = 15;
  healing = 0;
  refreshedRenews = 0;
  secsGained = 0;

  // This module will be tracking the initial application of renews, then recording
  // all renew healing done to those targets after a timestamp + base duration at
  // applybuff since all "refreshbuff" events for renew will be from direct heals
  // (the exception would be benediction renews refreshing but I'm not sure how to
  // counter that and it should be such a small portion of refreshs anyway). Thus,
  // all renew healing after timestamp + baase duraation should be a result of
  // Enduring Renewal

  constructor(options: any) {
    super(options);
    this.active = this.selectedCombatant.hasTalent(SPELLS.ENDURING_RENEWAL_TALENT.id);
  }

  // We do not track "casts" of Renew because casting Renew on an existing target
  // that has renew is also a "direct heal" that triggers Enduring Renewal.
  // It is up for debate whether or not direct heals from Renew should attribute
  // to Enduring Renewal, but for now I will say it does.
  on_byPlayer_applybuff(event: ApplyBuffEvent) {
    this.parseRenew(event); // function incase we decide to disclude manual renew refreshes
  }

  on_byPlayer_removebuff(event: RemoveBuffEvent) {
    const spellId = event.ability.guid;
    if (spellId !== SPELLS.RENEW.id) {
      return;
    }
    delete this._normalRenewDropoff[event.targetID];
    delete this._newRenewDropoff[event.targetID];
  }

  on_byPlayer_heal(event: HealEvent) {
    const spellId = event.ability.guid;
    if (spellId === SPELLS.RENEW.id) {
      if (this._normalRenewDropoff[event.targetID] !== undefined && event.timestamp > this._normalRenewDropoff[event.targetID]) {
        this.healing += event.amount;
      }
    } else if (ABILITIES_THAT_TRIGGER_ENDURING_RENEWAL.includes(spellId)) {
      if (this._newRenewDropoff[event.targetID] !== undefined) {
        const remaining = (this._newRenewDropoff[event.targetID] - event.timestamp) / 1000.0;
        const gain = Math.min((this._baseRenewLength + 6) - remaining, this._baseRenewLength); // be wary of pandemic but also wary of early refreshes
        this._newRenewDropoff[event.targetID] = event.timestamp + (gain * 1000);

        this.refreshedRenews += 1;
        this.secsGained += gain;
      }
    }
  }

  parseRenew(event: ApplyBuffEvent) {
    const spellId = event.ability.guid;
    if (spellId === SPELLS.RENEW.id) {
      this._normalRenewDropoff[event.targetID] = event.timestamp + this._baseRenewLength * 1000;
      this._newRenewDropoff[event.targetID] = event.timestamp + this._baseRenewLength * 1000;
    }
  }

  statistic() {
    return (
      <Statistic
        tooltip={`Refreshed Renews: ${this.refreshedRenews}`}
        size="flexible"
        category={STATISTIC_CATEGORY.TALENTS}
        position={STATISTIC_ORDER.OPTIONAL(1)}
      >
        <BoringSpellValueText spell={SPELLS.ENDURING_RENEWAL_TALENT}>
          <ItemHealingDone amount={this.healing} />
        </BoringSpellValueText>
      </Statistic>
    );
  }
}

export default EnduringRenewal;

{'fraction_non_alphanumeric': 0.10105697344676463, 'fraction_numerical': 0.008249548852797113, 'mean_word_length': 3.7310975609756096, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6719127', 'n_tokens_mistral': 2608, 'n_tokens_neox': 2487, 'n_words': 609}