<commit_before>import styles from './ContributeByWeekCalendar.css'

React = require('react')

export default class ContributeByWeekCalendar extends React.PureComponent
    componentDidMount: () ->
        if @table_div
            @table_div.scrollTo 10000, 0

    render: () ->
        submits = @props.calendar.byDay
        # startday is monday of "currentday minus 1 year"
        # lastday is sunday of current week
        startday = new Date()
        startday.setMonth(startday.getMonth() - 12)
        start = startday.getDate() - startday.getDay() + 1
        startday = new Date(startday.setDate(start))
        lastday = new Date()
        last = lastday.getDate() - lastday.getDay() + 7
        lastday = new Date(lastday.setDate(last))
        d = startday
        row = []
        column = []
        dayOfWeek = 0
        weeks = 0
        xMonth = {}
        while d <= lastday
            currDay = "#{d.getFullYear()}-#{d.getMonth() + 1}-#{d.getDate()}"
            if d.getDate() == 15 then xMonth[d.getMonth()] = weeks
            color = "#ebedf0"
            if submits and (currDay of submits)
                c = submits[currDay]
                if c < 3
                    color = "#9be9a8"
                else if c < 7
                    color = "#40c463"
                else if c < 10
                    color = "#30a14e"
                else
                    color = "#216e39"
            onClickFun = do (currDay) -> -> if submits and (currDay of submits) then @props.clickOnDay(currDay)
            title = currDay
            if submits and (currDay of submits)
                title += ": #{submits[currDay]}"
            column.push <rect key={currDay} onClick={onClickFun} width="11" height="11" x={weeks * 16} y={dayOfWeek * 15} fill={color}>
                    <title>{title}</title>
                </rect>
            dayOfWeek++
            if dayOfWeek == 7
                dayOfWeek = 0
                weeks++
                row.push <g key={weeks} transform="translate(16, 0)">{column}</g>
                column = []
            d.setDate d.getDate()+1<commit_msg>Fix calendar click<commit_after>import styles from './ContributeByWeekCalendar.css'

React = require('react')

export default class ContributeByWeekCalendar extends React.PureComponent
    componentDidMount: () ->
        if @table_div
            @table_div.scrollTo 10000, 0

    render: () ->
        submits = @props.calendar.byDay
        # startday is monday of "currentday minus 1 year"
        # lastday is sunday of current week
        startday = new Date()
        startday.setMonth(startday.getMonth() - 12)
        start = startday.getDate() - startday.getDay() + 1
        startday = new Date(startday.setDate(start))
        lastday = new Date()
        last = lastday.getDate() - lastday.getDay() + 7
        lastday = new Date(lastday.setDate(last))
        d = startday
        row = []
        column = []
        dayOfWeek = 0
        weeks = 0
        xMonth = {}
        while d <= lastday
            currDay = "#{d.getFullYear()}-#{d.getMonth() + 1}-#{d.getDate()}"
            if d.getDate() == 15 then xMonth[d.getMonth()] = weeks
            color = "#ebedf0"
            if submits and (currDay of submits)
                c = submits[currDay]
                if c < 3
                    color = "#9be9a8"
                else if c < 7
                    color = "#40c463"
                else if c < 10
                    color = "#30a14e"
                else
                    color = "#216e39"
            onClickFun = do (currDay) => => if submits and (currDay of submits) then @props.clickOnDay(currDay)
            title = currDay
            if submits and (currDay of submits)
                title += ": #{submits[currDay]}"
            column.push <rect key={currDay} onClick={onClickFun} width="11" height="11" x={weeks * 16} y={dayOfWeek * 15} fill={color}>
                    <title>{title}</title>
                </rect>
            dayOfWeek++
            if dayOfWeek == 7
                dayOfWeek = 0
                weeks++
                row.push <g key={weeks} transform="translate(16, 0)">{column}</g>
                column = []
            d.setDate d.getDate()+1
{'fraction_non_alphanumeric': 0.11784115012962526, 'fraction_numerical': 0.024510959226962056, 'mean_word_length': 1.5799392097264437, 'pattern_counts': {'":': 2, '<': 23, '<?xml version=': 0, '>': 23, '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': '3948055', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1208, 'n_words': 315}