<commit_before>'use strict';

const debug = false;
const chalk = require('chalk');

const qryFrags = {

    treatments: {

        q: {
            column: 'snippet(vtreatments, 1, "<b>", "</b>", "", 50) AS context',
            table: 'vtreatments ON treatments.treatmentId = vtreatments.treatmentId',
            condition: 'vtreatments MATCH @q'
        },

        data: {
            columns: ['id', 'treatments.treatmentId', 'treatmentTitle', 'doi AS articleDoi', 'zenodoDep', 'zoobank', 'articleTitle', 'publicationDate', 'journalTitle', 'journalYear', 'journalVolume', 'journalIssue', 'pages', 'authorityName', 'authorityYear', 'kingdom', 'phylum', '"order"', 'family', 'genus', 'species', 'status', 'taxonomicNameLabel', 'treatments.rank'],
            tables: ['treatments'],
            condition: ['treatments.deleted = 0']
        },

        stats: {

            specimens: {
                columns: ['Sum(specimenCount)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCount != ''"],
            },

            'male specimens': {
                columns: ['Sum(specimenCountMale)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountMale != ''"],
            },

            'female specimens': {
                columns: ['Sum(specimenCountFemale)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountFemale != ''"]
            },

            'treatments with specimens': {
                columns: ['Count(DISTINCT treatments.treatmentId)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCount != ''"]
            },

            'treatments with male specimens': {
                columns: ['Count(DISTINCT treatments.treatmentId)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountMale != ''"]
            },

            'treatments with female specimens': {
                columns: ['Count(DISTINCT treatments.treatmentId)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountFemale != ''"]
            },

            'figure citations': {
                columns: ['Count(figureCitationId)'], 
                tables: ['figureCitations JOIN treatments ON figureCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND figureCitations.deleted = 0"]
            }
        },

        count: {
            columns: ['Count(treatments.treatmentId) AS numOfRecords'],
            tables: ['treatments'],
            condition: ['treatments.deleted = 0']
        },

        facets: {

            // BLR-Website Issue 10: removed from facets
            // https://github.com/plazi/BLR-website/issues/10
            //
            // journalVolume: {
            //     columns: ['journalVolume', 'Count(journalVolume) AS c'],
            //     tables: ['treatments'],
            //     condition: ["treatments.deleted = 0 AND journalVolume != ''"]
            // },

            journalTitle: {
                columns: ['journalTitle', 'Count(journalTitle) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND journalTitle != ''"]
            },

            journalYear: {
                columns: ['journalYear', 'Count(journalYear) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND journalYear != ''"]
            },

            kingdom: {
                columns: ['kingdom', 'Count(kingdom) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND kingdom != ''"]
            },

            phylum: {
                columns: ['phylum', 'Count(phylum) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND phylum != ''"]
            },

            order: {
                columns: ['"order"', 'Count("order") AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND \"order\" != ''"]
            },

            family: {
                columns: ['family', 'Count(family) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND family != ''"]
            },

            genus: {
                columns: ['genus', 'Count(genus) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND genus != ''"]
            },

            status: {
                columns: ['status', 'Count(status) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND status != ''"]
            },

            rank: {
                columns: ['treatments.rank', 'Count(treatments.rank) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND treatments.rank != ''"]
            },

            species: {
                columns: ['species', 'Count(species) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND species != ''"]
            },

            collectionCode: {
                columns: ['collectionCode', 'Count(collectionCode) AS c'],
                tables: ['materialsCitations JOIN treatments on materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND collectionCode != ''"]
            }

        },

        sortable: ['journalYear'],
        sortcol: 'treatments.treatmentId',
        sortdir: 'ASC'
    
    },

    citations: {

        q: {<commit_msg>removed taxa ranks from treatment facets<commit_after>'use strict';

const debug = false;
const chalk = require('chalk');

const qryFrags = {

    treatments: {

        q: {
            column: 'snippet(vtreatments, 1, "<b>", "</b>", "", 50) AS context',
            table: 'vtreatments ON treatments.treatmentId = vtreatments.treatmentId',
            condition: 'vtreatments MATCH @q'
        },

        data: {
            columns: ['id', 'treatments.treatmentId', 'treatmentTitle', 'doi AS articleDoi', 'zenodoDep', 'zoobank', 'articleTitle', 'publicationDate', 'journalTitle', 'journalYear', 'journalVolume', 'journalIssue', 'pages', 'authorityName', 'authorityYear', 'kingdom', 'phylum', '"order"', 'family', 'genus', 'species', 'status', 'taxonomicNameLabel', 'treatments.rank'],
            tables: ['treatments'],
            condition: ['treatments.deleted = 0']
        },

        stats: {

            specimens: {
                columns: ['Sum(specimenCount)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCount != ''"],
            },

            'male specimens': {
                columns: ['Sum(specimenCountMale)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountMale != ''"],
            },

            'female specimens': {
                columns: ['Sum(specimenCountFemale)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountFemale != ''"]
            },

            'treatments with specimens': {
                columns: ['Count(DISTINCT treatments.treatmentId)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCount != ''"]
            },

            'treatments with male specimens': {
                columns: ['Count(DISTINCT treatments.treatmentId)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountMale != ''"]
            },

            'treatments with female specimens': {
                columns: ['Count(DISTINCT treatments.treatmentId)'], 
                tables: ['materialsCitations JOIN treatments ON materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND materialsCitations.deleted = 0 AND specimenCountFemale != ''"]
            },

            'figure citations': {
                columns: ['Count(figureCitationId)'], 
                tables: ['figureCitations JOIN treatments ON figureCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND figureCitations.deleted = 0"]
            }
        },

        count: {
            columns: ['Count(treatments.treatmentId) AS numOfRecords'],
            tables: ['treatments'],
            condition: ['treatments.deleted = 0']
        },

        facets: {

            // BLR-Website Issue 10: removed from facets
            // https://github.com/plazi/BLR-website/issues/10
            //
            // journalVolume: {
            //     columns: ['journalVolume', 'Count(journalVolume) AS c'],
            //     tables: ['treatments'],
            //     condition: ["treatments.deleted = 0 AND journalVolume != ''"]
            // },

            journalTitle: {
                columns: ['journalTitle', 'Count(journalTitle) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND journalTitle != ''"]
            },

            journalYear: {
                columns: ['journalYear', 'Count(journalYear) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND journalYear != ''"]
            },

            kingdom: {
                columns: ['kingdom', 'Count(kingdom) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND kingdom != ''"]
            },

            phylum: {
                columns: ['phylum', 'Count(phylum) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND phylum != ''"]
            },

            order: {
                columns: ['"order"', 'Count("order") AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND \"order\" != ''"]
            },

            family: {
                columns: ['family', 'Count(family) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND family != ''"]
            },

            genus: {
                columns: ['genus', 'Count(genus) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND genus != ''"]
            },

            status: {
                columns: ['status', 'Count(status) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND status != ''"]
            },

            // BLR-Website Issue 11: removed from facets
            // https://github.com/plazi/BLR-website/issues/11
            //
            // rank: {
            //     columns: ['treatments.rank', 'Count(treatments.rank) AS c'],
            //     tables: ['treatments'],
            //     condition: ["treatments.deleted = 0 AND treatments.rank != ''"]
            // },

            species: {
                columns: ['species', 'Count(species) AS c'],
                tables: ['treatments'],
                condition: ["treatments.deleted = 0 AND species != ''"]
            },

            collectionCode: {
                columns: ['collectionCode', 'Count(collectionCode) AS c'],
                tables: ['materialsCitations JOIN treatments on materialsCitations.treatmentId = treatments.treatmentId'],
                condition: ["treatments.deleted = 0 AND collectionCode != ''"]
            }

        },

        sortable: ['journalYear'],
        sortcol: 'treatments.treatmentId',
        sortdir: 'ASC'
    
    },

    citations: {

        q: {
{'fraction_non_alphanumeric': 0.13429130303942222, 'fraction_numerical': 0.005567258501354198, 'mean_word_length': 1.8537999141262345, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 3, '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': '6506680', 'n_tokens_mistral': 3665, 'n_tokens_neox': 3160, 'n_words': 788}