<commit_before>import Component from "../pure-render-component";
import { Map, TileLayer } from 'react-leaflet';
import Cluster from "./cluster";
import Location from "./location";
require("./style.less");

var aggregateLocations = locations => locations
    .groupBy(location => location.getIn(['locations', '_id']))
    .map(locations => locations.reduce((reducedLocation, location) => {
        return {
          "_id": location.getIn(['locations', '_id']),
          "name": location.getIn(['locations', 'name']),
          "amount": reducedLocation.amount + location.get('totalPlannedAmount'),
          "count": reducedLocation.count + location.get('recordsCount'),
          "coords": location.getIn(['locations', 'coordinates', 'coordinates']).toJS()
        }
      }, {
        "amount": 0,
        "count": 0
      }))
    .toArray();

export default class Planning extends Component{
  render(){
    var {locations} = this.props;
    var aggregatedLocations = aggregateLocations(locations);
    var maxAmount = Math.max(0, ...aggregatedLocations.map(location => location.amount));
    return (
        <div className="col-sm-12 content map-content">
          <Map center={[14.5, 105]} zoom={5}>
            <TileLayer
                url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
                attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
            />
            <Cluster maxAmount={maxAmount}>
              {aggregatedLocations.map(location => (
                <Location
                    key={location._id}
                    position={location.coords.reverse()}<commit_msg>OCVN-101 Reimplemented year filtering for planning<commit_after>import Component from "../pure-render-component";
import { Map, TileLayer } from 'react-leaflet';
import Cluster from "./cluster";
import Location from "./location";
require("./style.less");

var aggregateLocations = locations => locations
    .groupBy(location => location.getIn(['locations', '_id']))
    .map(locations => locations.reduce((reducedLocation, location) => {
        return {
          "_id": location.getIn(['locations', '_id']),
          "name": location.getIn(['locations', 'name']),
          "amount": reducedLocation.amount + location.get('totalPlannedAmount'),
          "count": reducedLocation.count + location.get('recordsCount'),
          "coords": location.getIn(['locations', 'coordinates', 'coordinates']).toJS()
        }
      }, {
        "amount": 0,
        "count": 0
      }))
    .toArray();

export default class Planning extends Component{
  render(){
    var {locations, years} = this.props;
    var filteredLocations = locations.filter(location => years.get(location.get('year'), false));
    var aggregatedLocations = aggregateLocations(filteredLocations);
    var maxAmount = Math.max(0, ...aggregatedLocations.map(location => location.amount));
    return (
        <div className="col-sm-12 content map-content">
          <Map center={[14.5, 105]} zoom={5}>
            <TileLayer
                url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
                attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
            />
            <Cluster maxAmount={maxAmount}>
              {aggregatedLocations.map(location => (
                <Location
                    key={location._id}
                    position={location.coords.reverse()}
{'fraction_non_alphanumeric': 0.16132789749563192, 'fraction_numerical': 0.00786255096097845, 'mean_word_length': 2.733695652173913, 'pattern_counts': {'":': 14, '<': 17, '<?xml version=': 0, '>': 28, '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': '6417160', 'n_tokens_mistral': 974, 'n_tokens_neox': 915, 'n_words': 188}