<commit_before>define([
    'models/proto/paged-collection', 'models/quest'
], function (Parent, Quest) {
    return Parent.extend({
        defaultCgi: ['comment_count=1'],
        baseUrl: '/api/quest',
        cgi: ['user', 'status', 'limit', 'offset', 'sort', 'order', 'unclaimed', 'tags', 'watchers', 'realm'],
        model: Quest,

        initialize: function () {
            Parent.prototype.initialize.apply(this, arguments);

            var order_flag = 1;
            if (this.options.order && this.options.order == 'desc') {
                order_flag = -1;
            }

            if (this.options.sort) {
                if (this.options.sort == 'leaderboard') {
                    // duplicates server-side sorting logic!
                    this.comparator = function(m1, m2) {
                        if (m1.like_count() > m2.like_count()) return -order_flag;
                        if (m2.like_count() > m1.like_count()) return order_flag;

                        if (m1.comment_count() > m2.comment_count()) return -order_flag;
                        if (m2.comment_count() > m1.comment_count()) return order_flag;
                        return 0;
                    };
                }
                else if (this.options.sort == 'manual') {
                    // duplicates server-side sorting logic!
                    this.comparator = function(m1, m2) {
                        var o1 = m1.get('order');
                        var o2 = m2.get('order');
                        var t1 = m1.get('ts');
                        var t2 = m2.get('ts');
                        if (o1 && o2) {
                            if (o1 < o2) { return -1 } else if (o1 > o2) { return 1 } else { return 0 }
                        }
                        else if (o1) {
                            return 1;
                        }
                        else if (o2) {
                            return -1;
                        }
                        else {
                            if (t1 < t2) { return 1 } else if (t1 > t2) { return -1 } else { return 0 }
                        }
                    };
                }
                else {
                    console.log("oops, unknown sort option " + this.options.sort);
                }
            }
            else {
                this.comparator = function(m1, m2) {
                    if (m1.id > m2.id) return order_flag;
                    if (m2.id > m1.id) return -order_flag;
                    return 0;
                };
            }
        },

        saveManualOrder: function (ids) {
            return $.post('/api/quest/set_manual_order', {
                'quest_ids[]': ids
            });
            mixpanel.track('set order');
        }
    });<commit_msg>fix set_manual_order calls tracking<commit_after>define([
    'models/proto/paged-collection', 'models/quest'
], function (Parent, Quest) {
    return Parent.extend({
        defaultCgi: ['comment_count=1'],
        baseUrl: '/api/quest',
        cgi: ['user', 'status', 'limit', 'offset', 'sort', 'order', 'unclaimed', 'tags', 'watchers', 'realm'],
        model: Quest,

        initialize: function () {
            Parent.prototype.initialize.apply(this, arguments);

            var order_flag = 1;
            if (this.options.order && this.options.order == 'desc') {
                order_flag = -1;
            }

            if (this.options.sort) {
                if (this.options.sort == 'leaderboard') {
                    // duplicates server-side sorting logic!
                    this.comparator = function(m1, m2) {
                        if (m1.like_count() > m2.like_count()) return -order_flag;
                        if (m2.like_count() > m1.like_count()) return order_flag;

                        if (m1.comment_count() > m2.comment_count()) return -order_flag;
                        if (m2.comment_count() > m1.comment_count()) return order_flag;
                        return 0;
                    };
                }
                else if (this.options.sort == 'manual') {
                    // duplicates server-side sorting logic!
                    this.comparator = function(m1, m2) {
                        var o1 = m1.get('order');
                        var o2 = m2.get('order');
                        var t1 = m1.get('ts');
                        var t2 = m2.get('ts');
                        if (o1 && o2) {
                            if (o1 < o2) { return -1 } else if (o1 > o2) { return 1 } else { return 0 }
                        }
                        else if (o1) {
                            return 1;
                        }
                        else if (o2) {
                            return -1;
                        }
                        else {
                            if (t1 < t2) { return 1 } else if (t1 > t2) { return -1 } else { return 0 }
                        }
                    };
                }
                else {
                    console.log("oops, unknown sort option " + this.options.sort);
                }
            }
            else {
                this.comparator = function(m1, m2) {
                    if (m1.id > m2.id) return order_flag;
                    if (m2.id > m1.id) return -order_flag;
                    return 0;
                };
            }
        },

        saveManualOrder: function (ids) {
            mixpanel.track('set order');
            return $.post('/api/quest/set_manual_order', {
                'quest_ids[]': ids
            });
        }
    });
{'fraction_non_alphanumeric': 0.12022832679272208, 'fraction_numerical': 0.018194791295041028, 'mean_word_length': 1.0053648068669527, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5300751', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1449, 'n_words': 339}