<commit_before>import { computed, observable } from "mobx"
import { ObservableUrl } from "../UrlBinding"
import { ChartUrl, EntityUrlBuilder } from "../ChartUrl"
import {
    QueryParams,
    strToQueryParams,
    queryParamsToStr
} from "utils/client/url"
import { SortOrder } from "charts/SortOrder"
import { omit, oneOf } from "../Util"
import {
    PerCapita,
    AlignedOption,
    SmoothingOption,
    colorScaleOption,
    MetricKind
} from "./CovidTypes"
import { CountryPickerMetric } from "./CovidCountryPickerMetric"

export class CovidQueryParams {
    // Todo: in hindsight these 6 metrics should have been something like "yColumn". May want to switch to that and translate these
    // for back compat.
    @observable casesMetric: boolean = false
    @observable testsMetric: boolean = false
    @observable testsPerCaseMetric: boolean = false
    @observable positiveTestRate: boolean = false
    @observable deathsMetric: boolean = false
    @observable cfrMetric: boolean = false

    @observable totalFreq: boolean = false
    @observable dailyFreq: boolean = false
    @observable perCapita: PerCapita = false
    @observable aligned: AlignedOption = false
    @observable hideControls: boolean = false
    @observable smoothing: SmoothingOption = 0
    @observable colorScale?: colorScaleOption = undefined

    // Country picker params
    @observable selectedCountryCodes: Set<string> = new Set(
        "USA GBR CAN BRA AUS IND ESP DEU FRA".split(" ")
    )
    @observable countryPickerMetric: CountryPickerMetric =
        CountryPickerMetric.location
    @observable countryPickerSort: SortOrder = SortOrder.asc

    constructor(queryString: string) {
        const params = strToQueryParams(queryString)
        if (params.casesMetric) this.casesMetric = true
        if (params.totalFreq) this.totalFreq = true
        if (params.testsMetric) this.testsMetric = true
        if (params.testsPerCaseMetric) this.testsPerCaseMetric = true
        if (params.positiveTestRate) this.positiveTestRate = true
        if (params.deathsMetric) this.deathsMetric = true
        if (params.cfrMetric) this.cfrMetric = true
        if (params.dailyFreq) this.dailyFreq = true
        if (params.perCapita) this.perCapita = true
        if (params.hideControls) this.hideControls = true
        if (params.aligned) this.aligned = true
        if (params.smoothing)
            this.smoothing = parseInt(params.smoothing) as SmoothingOption
        if (params.country) {<commit_msg>Cleanup: default countries now come from coronaDefaultView<commit_after>import { computed, observable } from "mobx"
import { ObservableUrl } from "../UrlBinding"
import { ChartUrl, EntityUrlBuilder } from "../ChartUrl"
import {
    QueryParams,
    strToQueryParams,
    queryParamsToStr
} from "utils/client/url"
import { SortOrder } from "charts/SortOrder"
import { omit, oneOf } from "../Util"
import {
    PerCapita,
    AlignedOption,
    SmoothingOption,
    colorScaleOption,
    MetricKind
} from "./CovidTypes"
import { CountryPickerMetric } from "./CovidCountryPickerMetric"

export class CovidQueryParams {
    // Todo: in hindsight these 6 metrics should have been something like "yColumn". May want to switch to that and translate these
    // for back compat.
    @observable casesMetric: boolean = false
    @observable testsMetric: boolean = false
    @observable testsPerCaseMetric: boolean = false
    @observable positiveTestRate: boolean = false
    @observable deathsMetric: boolean = false
    @observable cfrMetric: boolean = false

    @observable totalFreq: boolean = false
    @observable dailyFreq: boolean = false
    @observable perCapita: PerCapita = false
    @observable aligned: AlignedOption = false
    @observable hideControls: boolean = false
    @observable smoothing: SmoothingOption = 0
    @observable colorScale?: colorScaleOption = undefined

    // Country picker params
    @observable selectedCountryCodes: Set<string> = new Set()
    @observable countryPickerMetric: CountryPickerMetric =
        CountryPickerMetric.location
    @observable countryPickerSort: SortOrder = SortOrder.asc

    constructor(queryString: string) {
        const params = strToQueryParams(queryString)
        if (params.casesMetric) this.casesMetric = true
        if (params.totalFreq) this.totalFreq = true
        if (params.testsMetric) this.testsMetric = true
        if (params.testsPerCaseMetric) this.testsPerCaseMetric = true
        if (params.positiveTestRate) this.positiveTestRate = true
        if (params.deathsMetric) this.deathsMetric = true
        if (params.cfrMetric) this.cfrMetric = true
        if (params.dailyFreq) this.dailyFreq = true
        if (params.perCapita) this.perCapita = true
        if (params.hideControls) this.hideControls = true
        if (params.aligned) this.aligned = true
        if (params.smoothing)
            this.smoothing = parseInt(params.smoothing) as SmoothingOption
        if (params.country) {
{'fraction_non_alphanumeric': 0.08234585258083953, 'fraction_numerical': 0.0008033741715203856, 'mean_word_length': 3.4583706356311548, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '514511', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1359, 'n_words': 401}