<commit_before>
/* These are actually services */
var app = angular.module('InboxApp.models', []);

/* Using this strategy:
  http://stackoverflow.com/questions/13762228/confused-about-service-vs-factory
  */

/* Thread factory that provides a constructor so we can do something like:
var myThread = new Thread(some_thread_id, array_of_msg_ids);
This object type should only be accessible if it's injected.
Probably calling Thread.whatever() will be a class function, whereas
instance.whatever() will be one of the methods defined through prototype

Here's an explanation of how all of this reduces to factories.
https://groups.google.com/forum/#!msg/angular/56sdORWEoqg/b8hdPskxZXsJ

 */



app.factory('IBThread', function ($injector) {

    function IBThreadObject($rootScope, data) {
        this.$rootScope = $rootScope;
        // TODO handle default values here or when data=none
        this.message_ids = data.message_ids;
        this.thread_id = data.thread_id;
        this.labels = data.labels;
    }


    return function(data) {
      return $injector.instantiate(
        IBThreadObject, {data:data});
    };
});



app.factory('IBMessageMeta', function ($injector)
{
    function IBMessageMetaObject($rootScope, data) {
        this.$rootScope = $rootScope;

        // Propogate fields to the object
        for (var key in data) {
            if (self.hasOwnProperty(key)) {
                console.log(key + " -> " + p[key]);
            }
            this[key] = data[key];
        }
        // Fix the date
        this.date = new Date(data.date.$date);

        this.parts = {};


        var gravatar_size = 25;
        var theEmail = this.from[0][2] + '@' + this.from[0][3];
        this.gravatar_url = "http://www.gravatar.com/avatar/" +
                        md5( theEmail.toLowerCase() )+ "?" +
                        'd=mm&' +
                        's=' + encodeURIComponent(gravatar_size);


        if (this.to && this.to.length > 0) {

            var to_list;
            if (this.to[0][0] ) {
                to_list = this.to[0][0];
            } else {
                to_list = this.to[0][2] + '@' + this.to[0][3];
            }


            for (var i = 1; i< this.to.length; i++) {
                var c = this.to[i];
                var nameToShow;
                if (c[0]) {
                    nameToShow = c[0];
                } else {<commit_msg>gravatar over https<commit_after>
/* These are actually services */
var app = angular.module('InboxApp.models', []);

/* Using this strategy:
  http://stackoverflow.com/questions/13762228/confused-about-service-vs-factory
  */

/* Thread factory that provides a constructor so we can do something like:
var myThread = new Thread(some_thread_id, array_of_msg_ids);
This object type should only be accessible if it's injected.
Probably calling Thread.whatever() will be a class function, whereas
instance.whatever() will be one of the methods defined through prototype

Here's an explanation of how all of this reduces to factories.
https://groups.google.com/forum/#!msg/angular/56sdORWEoqg/b8hdPskxZXsJ

 */



app.factory('IBThread', function ($injector) {

    function IBThreadObject($rootScope, data) {
        this.$rootScope = $rootScope;
        // TODO handle default values here or when data=none
        this.message_ids = data.message_ids;
        this.thread_id = data.thread_id;
        this.labels = data.labels;
    }


    return function(data) {
      return $injector.instantiate(
        IBThreadObject, {data:data});
    };
});



app.factory('IBMessageMeta', function ($injector)
{
    function IBMessageMetaObject($rootScope, data) {
        this.$rootScope = $rootScope;

        // Propogate fields to the object
        for (var key in data) {
            if (self.hasOwnProperty(key)) {
                console.log(key + " -> " + p[key]);
            }
            this[key] = data[key];
        }
        // Fix the date
        this.date = new Date(data.date.$date);

        this.parts = {};


        var gravatar_size = 25;
        var theEmail = this.from[0][2] + '@' + this.from[0][3];
        this.gravatar_url = "https://www.gravatar.com/avatar/" +
                        md5( theEmail.toLowerCase() )+ "?" +
                        'd=mm&' +
                        's=' + encodeURIComponent(gravatar_size);


        if (this.to && this.to.length > 0) {

            var to_list;
            if (this.to[0][0] ) {
                to_list = this.to[0][0];
            } else {
                to_list = this.to[0][2] + '@' + this.to[0][3];
            }


            for (var i = 1; i< this.to.length; i++) {
                var c = this.to[i];
                var nameToShow;
                if (c[0]) {
                    nameToShow = c[0];
                } else {
{'fraction_non_alphanumeric': 0.12908598792421402, 'fraction_numerical': 0.012492192379762648, 'mean_word_length': 1.9709338280766853, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, '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': '3480291', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1417, 'n_words': 350}