<commit_before>(function (mw, $) {
    "use strict";
    mw.KQnaModule = function (embedPlayer,qnaPlugin,qnaService) {
        return this.init(embedPlayer,qnaPlugin,qnaService);
    };
    mw.KQnaModule.prototype = {

        // The bind postfix:
        bindPostfix: '.KQnaModule',
        qnaPlugin: null,
        qnaService: null,

        init: function (embedPlayer,qnaPlugin,qnaService) {

            var _this = this;
            // Remove any old bindings:
            this.destroy();
            // Setup player ref:
            this.embedPlayer = embedPlayer;
            this.qnaPlugin = qnaPlugin;
            this.qnaService = qnaService;
            this.myObservableArray = qnaService.getItems();

            this.myObservableArray.subscribe(function(newVal){
                _this.applyLayout();
                qnaPlugin.updateUnreadBadge();
            });

            this.itemRead= function(item, event) {
                console.log("item of type " + item.type + " with id " + item.threadId + " was clicked");

                _this.qnaService.markAsRead(item);
            }
        },
        destroy: function () {

            $(this.embedPlayer).unbind(this.bindPostfix);
        },
        applyLayout:function() {
            var _this = this;
            var scroll = _this.qnaPlugin.getQnaContainer().find(".nano")
            //var scroll=$( window['parent'].document ).find(".nano");
            scroll.find(".nano-content" ).css("z-index", -1);

            if ($(".qnaInterface").length > 0){
                scroll.nanoScroller();
            }
            else{
                scroll.nanoScroller({ documentContext: window['parent'].document});
            }
            scroll.find(".nano-content" ).css("z-index", "");
        },
        getUnreadCount: function(){
            var _this = this;
            // The commented line below is correct, but it also counts regular questions
            // so for now we do something else
            //return _this.myObservableArray().length - _this.qnaService.readThreadsCount();

            var count = 0;
            ko.utils.arrayForEach(_this.myObservableArray(), function(entry) {
                if (entry().tags == "QnaAnnouncement" && !_this.qnaService.viewedThreads.isRead(entry().id)){
                    count++;
                }
            });
            return count;
        }
    };
})(window.mw, window.jQuery);<commit_msg>Bug fix: badge should take into account the metadata and not tags<commit_after>(function (mw, $) {
    "use strict";
    mw.KQnaModule = function (embedPlayer,qnaPlugin,qnaService) {
        return this.init(embedPlayer,qnaPlugin,qnaService);
    };
    mw.KQnaModule.prototype = {

        // The bind postfix:
        bindPostfix: '.KQnaModule',
        qnaPlugin: null,
        qnaService: null,

        init: function (embedPlayer,qnaPlugin,qnaService) {

            var _this = this;
            // Remove any old bindings:
            this.destroy();
            // Setup player ref:
            this.embedPlayer = embedPlayer;
            this.qnaPlugin = qnaPlugin;
            this.qnaService = qnaService;
            this.myObservableArray = qnaService.getItems();

            this.myObservableArray.subscribe(function(newVal){
                _this.applyLayout();
                qnaPlugin.updateUnreadBadge();
            });

            this.itemRead= function(item, event) {
                console.log("item of type " + item.type + " with id " + item.threadId + " was clicked");

                _this.qnaService.markAsRead(item);
            }
        },
        destroy: function () {

            $(this.embedPlayer).unbind(this.bindPostfix);
        },
        applyLayout:function() {
            var _this = this;
            var scroll = _this.qnaPlugin.getQnaContainer().find(".nano")
            //var scroll=$( window['parent'].document ).find(".nano");
            scroll.find(".nano-content" ).css("z-index", -1);

            if ($(".qnaInterface").length > 0){
                scroll.nanoScroller();
            }
            else{
                scroll.nanoScroller({ documentContext: window['parent'].document});
            }
            scroll.find(".nano-content" ).css("z-index", "");
        },
        getUnreadCount: function(){
            var _this = this;
            // The commented line below is correct, but it also counts regular questions
            // so for now we do something else
            //return _this.myObservableArray().length - _this.qnaService.readThreadsCount();

            var count = 0;
            ko.utils.arrayForEach(_this.myObservableArray(), function(entry) {
                if (entry().metadata.Type === 'Announcement' && !_this.qnaService.viewedThreads.isRead(entry().id)){
                    count++;
                }
            });
            return count;

        }
    };
})(window.mw, window.jQuery);
{'fraction_non_alphanumeric': 0.12774167343623072, 'fraction_numerical': 0.0012185215272136475, 'mean_word_length': 1.739154616240267, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7371884', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1320, 'n_words': 260}