<commit_before>import React from 'react';
import { connect } from 'react-redux';
import { Tooltip } from 'react-leaflet';
import PropTypes from 'prop-types';

import MarkerWithInnerLabel from 'fm3/components/leaflet/MarkerWithInnerLabel';
import { toastsAdd } from 'fm3/actions/toastsActions';
import { changesetsSetAuthorName } from 'fm3/actions/changesetsActions';

import 'fm3/styles/changesets.scss';

const timeFormat = new Intl.DateTimeFormat('sk',
  { day: '2-digit', month: '2-digit', hour: 'numeric', minute: '2-digit' });

const ONE_DAY = (1000 * 60 * 60 * 24);

class Changesets extends React.Component {
  opacityOf = (changeset, now) => {
    const changesetAgeInDays = (now - changeset.closedAt) / ONE_DAY;
    const freshness = (changesetAgeInDays / this.props.days); // <0.0, 1.0>
    return freshness * 0.4 + 0.6; // <0.6, 1.0> . markers with opacity below 0.6 are almost invisible
  }

  render() {
    const { changesets, onShowChangesetDetail } = this.props;
    const now = new Date();
    return (
      <div>
        { changesets.map((changeset) => {
          const opacity = this.opacityOf(changeset, now);
          return (<MarkerWithInnerLabel
            faIcon="pencil"
            opacity={opacity}
            key={changeset.id}
            faIconLeftPadding="2px"
            position={L.latLng(changeset.centerLat, changeset.centerLon)}
            onClick={() => onShowChangesetDetail(changeset)}
          >
            <Tooltip opacity={opacity} className="compact" offset={new L.Point(9, -25)} direction="right" permanent>
              <div className="shortened">
                <b>{changeset.userName}: </b>
                {changeset.description}
              </div>
            </Tooltip>
          </MarkerWithInnerLabel>);
        }) }<commit_msg>#153: fix changeset opacity bug<commit_after>import React from 'react';
import { connect } from 'react-redux';
import { Tooltip } from 'react-leaflet';
import PropTypes from 'prop-types';

import MarkerWithInnerLabel from 'fm3/components/leaflet/MarkerWithInnerLabel';
import { toastsAdd } from 'fm3/actions/toastsActions';
import { changesetsSetAuthorName } from 'fm3/actions/changesetsActions';

import 'fm3/styles/changesets.scss';

const timeFormat = new Intl.DateTimeFormat('sk',
  { day: '2-digit', month: '2-digit', hour: 'numeric', minute: '2-digit' });

const ONE_DAY = (1000 * 60 * 60 * 24);

class Changesets extends React.Component {
  opacityOf = (changeset, now) => {
    const changesetAgeInDays = (now - changeset.closedAt) / ONE_DAY;
    const freshness = ((this.props.days - changesetAgeInDays) / this.props.days); // <0.0, 1.0>
    const opacity = freshness * 0.4 + 0.6; // <0.6, 1.0> . markers with opacity below 0.6 are almost invisible
    return opacity;
  }

  render() {
    const { changesets, onShowChangesetDetail } = this.props;
    const now = new Date();
    return (
      <div>
        { changesets.map((changeset) => {
          const opacity = this.opacityOf(changeset, now);
          return (<MarkerWithInnerLabel
            faIcon="pencil"
            opacity={opacity}
            key={changeset.id}
            faIconLeftPadding="2px"
            position={L.latLng(changeset.centerLat, changeset.centerLon)}
            onClick={() => onShowChangesetDetail(changeset)}
          >
            <Tooltip opacity={opacity} className="compact" offset={new L.Point(9, -25)} direction="right" permanent>
              <div className="shortened">
                <b>{changeset.userName}: </b>
                {changeset.description}
              </div>
            </Tooltip>
          </MarkerWithInnerLabel>);
        }) }
{'fraction_non_alphanumeric': 0.1349575691212702, 'fraction_numerical': 0.019983575143717493, 'mean_word_length': 2.7983367983367984, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, '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': '6585641', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1093, 'n_words': 252}