<commit_before>
define [
    'app/models',
    'app/spinner',
    'app/embedded-views',
    'backbone.marionette',
    'jquery'
], (
    models,
    Spinner,
    TitleBarView
    Marionette,
    $
) ->

    PAGE_SIZE = 1000
    delayTime = 1000
    spinner = new Spinner
        container: document.body

    class Router extends Marionette.AppRouter
        routes:
            'embed/unit/:id': 'renderUnit',
            'embed/unit/?*params': 'renderUnitsWithFilter',
            'embed/area/?*params': 'renderArea'

        execute: (callback, args) ->
            _.delay @indicateLoading, delayTime
            model = callback.apply(@, args)
            @listenTo model, 'sync', @removeLoadingIndicator
            @listenTo model, 'finished', @removeLoadingIndicator

        drawUnits: (units, opts) =>
            @mapView.drawUnits units, opts or zoom: true

        initialize: (@app, @appState, @mapView) ->

        _fetchDivisions: (divisionIds) ->
            @appState.divisions
                .setFilter 'ocd_id', divisionIds.join(',')
                .setFilter 'geometry', true
                .fetch()

        _parseParameters: (params) ->
            parsedParams = {}
            _(params.split '&').each (query) =>
                [k, v] = query.split('=', 2)
                if v.match /,/
                    v = v.split(',')
                else
                    v = [v]
                parsedParams[k] = v
            parsedParams

        renderUnit: (id)->
            unit = new models.Unit id: id
            @appState.units = new models.UnitList [unit]
            @listenToOnce unit, 'sync', => @drawUnits @appState.units
            unit.fetch()
            unit

        renderUnitsWithFilter: (params) ->
            @listenToOnce @appState.units, 'sync', @drawUnits
            units =  @appState.units
            params = @_parseParameters params
            key = 'division'<commit_msg>Enable embedded division filter view.<commit_after>
define [
    'app/models',
    'app/spinner',
    'app/embedded-views',
    'backbone.marionette',
    'jquery'
], (
    models,
    Spinner,
    TitleBarView
    Marionette,
    $
) ->

    PAGE_SIZE = 1000
    delayTime = 1000
    spinner = new Spinner
        container: document.body

    class Router extends Marionette.AppRouter
        routes:
            'embed/unit/:id': 'renderUnit',
            'embed/unit/?*params': 'renderUnitsWithFilter',
            'embed/area/?*params': 'renderArea'

        execute: (callback, args) ->
            _.delay @indicateLoading, delayTime
            model = callback.apply(@, args)
            @listenTo model, 'sync', @removeLoadingIndicator
            @listenTo model, 'finished', @removeLoadingIndicator

        drawUnits: (units, opts) =>
            @mapView.drawUnits units, opts or zoom: true

        initialize: (@app, @appState, @mapView) ->

        _fetchDivisions: (divisionIds) ->
            @appState.divisions
                .setFilter 'ocd_id', divisionIds.join(',')
                .setFilter 'geometry', true
                .fetch()

        _parseParameters: (params) ->
            parsedParams = {}
            _(params.split '&').each (query) =>
                [k, v] = query.split('=', 2)
                if v.match /,/
                    v = v.split(',')
                else
                    v = [v]
                parsedParams[k] = v
            parsedParams

        renderUnit: (id)->
            unit = new models.Unit id: id
            @appState.units = new models.UnitList [unit]
            @listenToOnce unit, 'sync', => @drawUnits @appState.units
            unit.fetch()
            unit

        renderUnitsWithFilter: (params) ->
            console.trace()
            @listenToOnce @appState.units, 'sync', =>
                @drawUnits @appState.units
            units =  @appState.units
            params = @_parseParameters params
            key = 'division'
{'fraction_non_alphanumeric': 0.12047582890407492, 'fraction_numerical': 0.004555808656036446, 'mean_word_length': 1.6189529489728296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, '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': '2924565', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1096, 'n_words': 249}