<commit_before><activities>
    <h3 class="subtitle">{ t('Recent Activities') }</h3>

    <ul class="top-bar list-bare">
        <li each="{ activities }">

            <div class="activity-date">
                { formatDate(date) }
                <img class="icon" src="{ getIcon(this) }">
            </div><!--
                avoid space
        --><div class="activity-content">

                <!-- If is a thread update -->
                <div if="{ comments }">
                    { t('comments_about', {'_num': comments.length}) }
                    <a if="{ multiPontinfo }"
                        class="clickable"
                        onclick="{ fRoute('despesa', {code:thread_name}) }">
                        { multiPontinfo.value[thread_name]['ds_projeto_atividade'] }
                    </a>
                </div>

                <!-- If is a pedido update -->
                <div if="{ pedido }"
                    class="clickable"
                    onclick="{ fRoute('despesa', {code:code}) }">
                    Pergunta: { pedido.justification }
                </div>

                <!-- If is a money update -->
                <div if="{ data }">
                    <div if="{ event == 'modified' }">
                        <a class="clickable"
                            onclick="{ fRoute('despesa', {code:code}) }">
                            {description}
                        </a>
                        mudou de
                        {data.state[0]}
                        para
                        <b>{data.state[1]}</b>
                    </div>
                    <div if="{ event == 'created' }">
                        Novo:
                        <a class="clickable"
                            onclick="{ fRoute('despesa', {code:code}) }">
                            {description}
                        </a>
                    </div>
                </div>

            </div>

        </li>
    </ul>


    <script type="es6">
    import {formatDate} from '../utils/helpers'
    this.formatDate = formatDate
    this.mixin('base')

    this.activities = []
    this.threads = []
    this.pedidos = []
    this.moneys = []

    this.dateCompare = (a, b) => a.date < b.date ? 1 : -1

    this.updateActivities = () => {
        this.activities = this.pedidos
                              .concat(this.threads)
                              .concat(this.moneys)
                              .sort(this.dateCompare)
    }

    this.watch('multiPontinfo', () => {
        this.update()
    })

    this.watch('moneyUpdates', () => {
        this.moneys = []
        for (let row of this.moneyUpdates.value) {
            this.moneys.push(row)
        }
        this.updateActivities()
    })

    this.watch('pedidosUpdates', () => {
        if (this.pedidosUpdates && this.pedidosUpdates.value) {
            this.pedidos = []
            for (let pedido of this.pedidosUpdates.value) {

                // Hide external pedidos
                if (pedido.keywords[0] != 'recuperado') {
                    this.pedidos.push({
                        date: pedido.date,
                        code: pedido.keywords[0],
                        pedido
                    })
                }
            }
            this.updateActivities()
        }
    })

    this.watch('commentsUpdates', () => {
        this.threads = []
        // Group comments by thread
        if (this.commentsUpdates.value) {
            threadsMap = this.commentsUpdates.value.reduce((threads, curr) => {
                if (threads[curr.thread_name]) {
                    threads[curr.thread_name].push(curr)
                } else {
                    let comments = [curr]
                    threads[curr.thread_name] = comments
                    this.threads.push({
                        date: curr.created,
                        thread_name: curr.thread_name,
                        comments
                    })
                }
                return threads
            }, {})

            let codes = Object.keys(threadsMap)
            this.updateActivities()
            this.triggerChange('multiPontinfo', {key: 'a', codes})
        }
    })

    // Get the icon for an activity
    this.getIcon = (item) => {
        if (item.data) {
            // Is a money update
            if (item.event == 'modified')
                var currState = item.data.state[1]
            else
                var currState = item.data.state
            if (currState == 'empenhado') return this.assets.aEmp
            if (currState == 'liquidado') return this.assets.aLiq
            if (currState == 'orcado' || currState == 'atualizado')
                return this.assets.aPla
        } else if (item.comments) {
            // Is a comments update
            if (item.comments.length > 4) return this.assets.aComExtra
            else return this.assets.aCom
        } else if (item.pedido) {
            // Is a pergunta update
            return this.assets.aPer
        }
        return ''
    }

    // this.on('mount', () => {
    //     console.log('MOOOOOOOOOO')
    //     this.interval = setInterval(() => {
    //         console.log('Oi!')
    //     }, 1000)
    // })
    // this.on('unmount', () => window.clearInterval(this.interval))
    </script>
</activities>
<commit_msg>fix to set year when going from activity to despesa<commit_after><activities>
    <h3 class="subtitle">{ t('Recent Activities') }</h3>

    <ul class="top-bar list-bare">
        <li each="{ activities }">

            <div class="activity-date">
                { formatDate(date) }
                <img class="icon" src="{ getIcon(this) }">
            </div><!--
                avoid space
        --><div class="activity-content">

                <!-- If is a thread update -->
                <div if="{ comments }">
                    { t('comments_about', {'_num': comments.length}) }
                    <a if="{ multiPontinfo }"
                        class="clickable"
                        onclick="{ fGoDespesa(thread_name) }">
                        { multiPontinfo.value[thread_name]['ds_projeto_atividade'] }
                    </a>
                </div>

                <!-- If is a pedido update -->
                <div if="{ pedido }"
                    class="clickable"
                    onclick="{ fGoDespesa(code) }">
                    Pergunta: { pedido.justification }
                </div>

                <!-- If is a money update -->
                <div if="{ data }">
                    <div if="{ event == 'modified' }">
                        <a class="clickable"
                            onclick="{ fGoDespesa(code) }">
                            {description}
                        </a>
                        mudou de
                        {data.state[0]}
                        para
                        <b>{data.state[1]}</b>
                    </div>
                    <div if="{ event == 'created' }">
                        Novo:
                        <a class="clickable"
                            onclick="{ fGoDespesa(code) }">
                            {description}
                        </a>
                    </div>
                </div>

            </div>

        </li>
    </ul>


    <script type="es6">
    import {formatDate} from '../utils/helpers'
    this.formatDate = formatDate
    this.mixin('base')

    this.activities = []
    this.threads = []
    this.pedidos = []
    this.moneys = []

    this.dateCompare = (a, b) => a.date < b.date ? 1 : -1

    this.updateActivities = () => {
        this.activities = this.pedidos
                              .concat(this.threads)
                              .concat(this.moneys)
                              .sort(this.dateCompare)
    }

    this.watch('multiPontinfo', () => {
        this.update()
    })

    this.watch('moneyUpdates', () => {
        this.moneys = []
        for (let row of this.moneyUpdates.value) {
            this.moneys.push(row)
        }
        this.updateActivities()
    })

    this.watch('pedidosUpdates', () => {
        if (this.pedidosUpdates && this.pedidosUpdates.value) {
            this.pedidos = []
            for (let pedido of this.pedidosUpdates.value) {

                // Hide external pedidos
                if (pedido.keywords[0] != 'recuperado') {
                    this.pedidos.push({
                        date: pedido.date,
                        code: pedido.keywords[0],
                        pedido
                    })
                }
            }
            this.updateActivities()
        }
    })

    this.watch('commentsUpdates', () => {
        this.threads = []
        // Group comments by thread
        if (this.commentsUpdates.value) {
            threadsMap = this.commentsUpdates.value.reduce((threads, curr) => {
                if (threads[curr.thread_name]) {
                    threads[curr.thread_name].push(curr)
                } else {
                    let comments = [curr]
                    threads[curr.thread_name] = comments
                    this.threads.push({
                        date: curr.created,
                        thread_name: curr.thread_name,
                        comments
                    })
                }
                return threads
            }, {})

            let codes = Object.keys(threadsMap)
            this.updateActivities()
            this.triggerChange('multiPontinfo', {key: 'a', codes})
        }
    })

    // Returns a function that when called routes to the given despesa page.
    // Tries to set the year accordingly.
    this.fGoDespesa = (code) => {
        if (code) {
            let params = {code: code}
            try {
                let year = code.slice(0, 4)
                parseInt(year)
                params['year'] = year
            } catch(err) {}
            return this.fRoute('despesa', params)
        }
    }

    // Get the icon for an activity
    this.getIcon = (item) => {
        if (item.data) {
            // Is a money update
            if (item.event == 'modified')
                var currState = item.data.state[1]
            else
                var currState = item.data.state
            if (currState == 'empenhado') return this.assets.aEmp
            if (currState == 'liquidado') return this.assets.aLiq
            if (currState == 'orcado' || currState == 'atualizado')
                return this.assets.aPla
        } else if (item.comments) {
            // Is a comments update
            if (item.comments.length > 4) return this.assets.aComExtra
            else return this.assets.aCom
        } else if (item.pedido) {
            // Is a pergunta update
            return this.assets.aPer
        }
        return ''
    }

    // this.on('mount', () => {
    //     console.log('MOOOOOOOOOO')
    //     this.interval = setInterval(() => {
    //         console.log('Oi!')
    //     }, 1000)
    // })
    // this.on('unmount', () => window.clearInterval(this.interval))
    </script>
</activities>

{'fraction_non_alphanumeric': 0.13036851071460592, 'fraction_numerical': 0.0028691831794136107, 'mean_word_length': 1.131066106228506, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 102, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4797631', 'n_tokens_mistral': 3107, 'n_tokens_neox': 2920, 'n_words': 591}