<commit_before>define(
   [
    '../config',
    'mustache', 
    'backbone',
    'model',
    'text!views/Menu.html'
    ], 
    function(config, Mustache, Backbone, model, template){

    return Backbone.View.extend({
        initialize: function(){
        },
        render: function(){
            $('.navbar').html(Mustache.render(template));
            this.delegateEvents();
        },
        events: {
            "click a": "make_menu_item_active",
            "click #delete_all_docs": "delete_all_docs",
            "click #delete_all_opc_cgroups": "delete_all_opc_cgroups",
            "click #delete_all_directories": "delete_all_directories",
            "click #delete_all_caney_opc": "delete_all_caney_opc",
            "click #delete_all_opc_data": "delete_all_abbreviation_data",
            "click #delete_all_pca_data": "delete_all_abbreviation_data",
            "click #delete_all_rpcna_data": "delete_all_abbreviation_data"
        },
        make_menu_item_active:function(event){
            // Remove the 'active' class from all other menu items
            $('.navbar li.active').removeClass('active')
            // Add the "active" class to the menu item the user clicked
            $(event.target).parent('li').addClass('active')
        },
        delete_all_docs:function(){
            // Delete all docs except design doc
            // Get all docs
            config.db.view('rcl/byCollection',{
                success:function(data){
                    var docs = []
                    for (var i=0;i<data.rows.length;i++){
                        docs.push({
                            _id:data.rows[i].id,
                            _rev:data.rows[i].value._rev
                        })
                    }
                    config.db.bulkRemove({docs:docs}, {})
                }
            })
        },
        delete_all_directories:function(){
            // Delete all directories
            // Get all directories from db
            config.db.view('rcl/directories',{
                success:function(data){
                    var docs = []
                    for (var i=0;i<data.rows.length;i++){
                        docs.push({
                            _id:data.rows[i].id,
                            _rev:data.rows[i].value
                        })
                        // Destroy using Backbone.Model.destroy() rather than CouchDB's config.db.bulkRemove().
                        var dir = model.Directory.findOrCreate(data.rows[i].id)
                        dir.destroy()
                    }
                    // config.db.bulkRemove({docs:docs}, {})
                }
            })
        },
        delete_all_caney_opc:function(){
            // Delete all OPC directories
            // Get all OPC congregations
            config.db.view('rcl/caney_opc',{
                keys:['Caney OPC', 'Caney OPC, second version', 'Caney OPC, third version',
                      'Bartlesville OPC'],
                success:function(data){
                    var docs = []
                    for (var i=0;i<data.rows.length;i++){
                        docs.push({
                            _id:data.rows[i].id,
                            _rev:data.rows[i].value
                        })
                    }
                    config.db.bulkRemove({docs:docs}, {})
                }
            })
        },
        delete_all_opc_cgroups:function(){<commit_msg>Use Backbone's methods to fetch and destroy all directories<commit_after>define(
   [
    '../config',
    'mustache', 
    'backbone',
    'model',
    'text!views/Menu.html'
    ], 
    function(config, Mustache, Backbone, model, template){

    return Backbone.View.extend({
        initialize: function(){
        },
        render: function(){
            $('.navbar').html(Mustache.render(template));
            this.delegateEvents();
        },
        events: {
            "click a": "make_menu_item_active",
            "click #delete_all_docs": "delete_all_docs",
            "click #delete_all_opc_cgroups": "delete_all_opc_cgroups",
            "click #delete_all_directories": "delete_all_directories",
            "click #delete_all_caney_opc": "delete_all_caney_opc",
            "click #delete_all_opc_data": "delete_all_abbreviation_data",
            "click #delete_all_pca_data": "delete_all_abbreviation_data",
            "click #delete_all_rpcna_data": "delete_all_abbreviation_data"
        },
        make_menu_item_active:function(event){
            // Remove the 'active' class from all other menu items
            $('.navbar li.active').removeClass('active')
            // Add the "active" class to the menu item the user clicked
            $(event.target).parent('li').addClass('active')
        },
        delete_all_docs:function(){
            // Delete all docs except design doc
            // Get all docs
            config.db.view('rcl/byCollection',{
                success:function(data){
                    var docs = []
                    for (var i=0;i<data.rows.length;i++){
                        docs.push({
                            _id:data.rows[i].id,
                            _rev:data.rows[i].value._rev
                        })
                    }
                    config.db.bulkRemove({docs:docs}, {})
                }
            })
        },
        delete_all_directories:function(){
            // Delete all directories
            var dirs = new model.Directories()
            dirs.fetch({success:function(dirs){
                dirs.each(function(dir){
                    dir.destroy()
                })
            }})
        },
        delete_all_caney_opc:function(){
            // Delete all OPC directories
            // Get all OPC congregations
            config.db.view('rcl/caney_opc',{
                keys:['Caney OPC', 'Caney OPC, second version', 'Caney OPC, third version',
                      'Bartlesville OPC'],
                success:function(data){
                    var docs = []
                    for (var i=0;i<data.rows.length;i++){
                        docs.push({
                            _id:data.rows[i].id,
                            _rev:data.rows[i].value
                        })
                    }
                    config.db.bulkRemove({docs:docs}, {})
                }
            })
        },
        delete_all_opc_cgroups:function(){
{'fraction_non_alphanumeric': 0.11838634600465477, 'fraction_numerical': 0.0007757951900698216, 'mean_word_length': 1.358580314672521, 'pattern_counts': {'":': 16, '<': 8, '<?xml version=': 0, '>': 3, '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': '647822', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1705, 'n_words': 293}