<commit_before>import * as React from 'react'
import {observable, runInAction} from 'mobx'
import {observer} from 'mobx-react'
const timeago = require('timeago.js')()

import Admin from './Admin'

interface BuildStatus {
    state: string
    created_at: string
    updated_at: string
    published_at: string
    admin_url: string
    build_id: string
}

@observer
export default class GrapherBuildStatus extends React.Component {
    context: { admin: Admin }

    @observable buildStatus?: BuildStatus

    request?: Promise<any>
    async updateStatus() {
        try {
            this.request = this.context.admin.rawRequest("/api/buildStatus.json", {}, "GET")
            const response = await this.request
            const json = await response.json()
            runInAction(() => this.buildStatus = json)
        } catch (err) {
            console.error(err)
        } finally {
            this.request = undefined
        }
    }

    interval: NodeJS.Timer
    componentDidMount() {
        this.interval = setInterval(() => {
            if (!this.request)
                this.updateStatus()
        }, 10000)
        this.updateStatus()
    }

    componentWillUnmount() {
        clearInterval(this.interval)
    }

    render() {
        const {buildStatus} = this
        if (!buildStatus)
            return null

        return <a className="nav-link" href={`${buildStatus.admin_url}/deploys/${buildStatus.build_id}`} target="_blank">
            {buildStatus.state === "ready" && <span style={{ color: 'lightgreen' }}>Last static build: {timeago.format(buildStatus.published_at)}</span>}
            {(buildStatus.state === "building" || buildStatus.state === "processing") && <span>Static build started {timeago.format(buildStatus.created_at)}...</span>}
            {buildStatus.state !== "ready" && buildStatus.state !== "building" && buildStatus.state !== "processing" && <span style={{ color: 'red' }}>Build error: {timeago.format(buildStatus.updated_at)}</span>}
        </a>
    }
}<commit_msg>Use the right build id<commit_after>import * as React from 'react'
import {observable, runInAction} from 'mobx'
import {observer} from 'mobx-react'
const timeago = require('timeago.js')()

import Admin from './Admin'

interface BuildStatus {
    state: string
    created_at: string
    updated_at: string
    published_at: string
    admin_url: string
    id: string
}

@observer
export default class GrapherBuildStatus extends React.Component {
    context: { admin: Admin }

    @observable buildStatus?: BuildStatus

    request?: Promise<any>
    async updateStatus() {
        try {
            this.request = this.context.admin.rawRequest("/api/buildStatus.json", {}, "GET")
            const response = await this.request
            const json = await response.json()
            runInAction(() => this.buildStatus = json)
        } catch (err) {
            console.error(err)
        } finally {
            this.request = undefined
        }
    }

    interval: NodeJS.Timer
    componentDidMount() {
        this.interval = setInterval(() => {
            if (!this.request)
                this.updateStatus()
        }, 10000)
        this.updateStatus()
    }

    componentWillUnmount() {
        clearInterval(this.interval)
    }

    render() {
        const {buildStatus} = this
        if (!buildStatus)
            return null

        return <a className="nav-link" href={`${buildStatus.admin_url}/deploys/${buildStatus.id}`} target="_blank">
            {buildStatus.state === "ready" && <span style={{ color: 'lightgreen' }}>Last static build: {timeago.format(buildStatus.published_at)}</span>}
            {(buildStatus.state === "building" || buildStatus.state === "processing") && <span>Static build started {timeago.format(buildStatus.created_at)}...</span>}
            {buildStatus.state !== "ready" && buildStatus.state !== "building" && buildStatus.state !== "processing" && <span style={{ color: 'red' }}>Build error: {timeago.format(buildStatus.updated_at)}</span>}
        </a>
    }
}
{'fraction_non_alphanumeric': 0.13879970363052604, 'fraction_numerical': 0.0024697456162015314, 'mean_word_length': 2.6851683348498634, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, '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': '1760831', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1129, 'n_words': 264}