<commit_before>americano = require 'americano-cozy'

# Required to get locale and domain data.
module.exports = CozyInstance = americano.getModel 'CozyInstance',
    id: String
    domain: String
    locale : String


CozyInstance.first = (callback) ->
    CozyInstance.request 'all', (err, instances) ->
        if err then callback err
        else if not instances or instances.length is 0 then callback null, null
        else callback null, instances[0]


CozyInstance.getLocale = (callback) ->
    CozyInstance.request 'all', (err, instances) ->
        console.log err if err
        callback null, instances?[0]?.locale or 'en'


CozyInstance.getURL = (callback) ->
    CozyInstance.first (err, instance) ->
        if err then callback err
        else if instance?.domain
            url = instance.domain
            .replace('http://', '')
            .replace('https://', '')
            callback null, "https://#{url}/"
        else
            callback new Error 'No instance domain set'<commit_msg>allow unedefined domain for development environment<commit_after>americano = require 'americano-cozy'

# Required to get locale and domain data.
module.exports = CozyInstance = americano.getModel 'CozyInstance',
    id: String
    domain: String
    locale : String


CozyInstance.first = (callback) ->
    CozyInstance.request 'all', (err, instances) ->
        if err then callback err
        else if not instances or instances.length is 0 then callback null, null
        else callback null, instances[0]


CozyInstance.getLocale = (callback) ->
    CozyInstance.request 'all', (err, instances) ->
        console.log err if err
        callback null, instances?[0]?.locale or 'en'


CozyInstance.getURL = (callback) ->
    CozyInstance.first (err, instance) ->
        if err then callback err
        else if instance?.domain
            url = instance.domain
            .replace('http://', '')
            .replace('https://', '')
            callback null, "https://#{url}/"
        else
            callback null, "http://localhost:9119/"
{'fraction_non_alphanumeric': 0.11251212415130941, 'fraction_numerical': 0.004849660523763337, 'mean_word_length': 2.5144804088586032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 4, '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': '2118086', 'n_tokens_mistral': 560, 'n_tokens_neox': 551, 'n_words': 180}