<commit_before>var azure = require('azure');

var TABLE_NAME = "messages";

function AzureArchiveProvider(config, log) {
    this.log = log;
    var azure_storage_account = config.azure_storage_account || process.env.AZURE_STORAGE_ACCOUNT;
    var azure_storage_key = config.azure_storage_key || process.env.AZURE_STORAGE_KEY;

    if (!azure_storage_account || !azure_storage_key) {
        this.log.warn("WARNING: Azure storage account or key not configured.  Set AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_KEY as environment variables to configure the azure blob provider.");
        return;
    }

    var retryOperations = new azure.ExponentialRetryPolicyFilter();

    this.azureTableService = azure.createTableService(
        azure_storage_account,
        azure_storage_key
    ).withFilter(retryOperations);

    this.azureTableService.createTableIfNotExists(TABLE_NAME, function() {});
}

AzureArchiveProvider.prototype.archive = function(message, callback) {
    var messageObject = message.toObject();

    messageObject.PartitionKey = messageObject.from;
    messageObject.RowKey = messageObject.ts;

    messageObject.body = JSON.stringify(messageObject.body);
    messageObject.tags = JSON.stringify(messageObject.tags);
    messageObject.response_to = JSON.stringify(messageObject.response_to);
    messageObject.visible_to = JSON.stringify(messageObject.visible_to);

    this.azureTableService.insertEntity(TABLE_NAME, messageObject, callback);
};

module.exports = AzureArchiveProvider;<commit_msg>Update archive.js<commit_after>var azure = require('azure')
  , moment = require('moment');

var TABLE_NAME = "messages";

function AzureArchiveProvider(config, log) {
    this.log = log;
    var azure_storage_account = config.azure_storage_account || process.env.AZURE_STORAGE_ACCOUNT;
    var azure_storage_key = config.azure_storage_key || process.env.AZURE_STORAGE_KEY;

    if (!azure_storage_account || !azure_storage_key) {
        this.log.warn("WARNING: Azure storage account or key not configured.  Set AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_KEY as environment variables to configure the azure blob provider.");
        return;
    }

    var retryOperations = new azure.ExponentialRetryPolicyFilter();

    this.azureTableService = azure.createTableService(
        azure_storage_account,
        azure_storage_key
    ).withFilter(retryOperations);

    this.azureTableService.createTableIfNotExists(TABLE_NAME, function() {});
}

AzureArchiveProvider.prototype.archive = function(message, callback) {
    var messageObject = message.toObject();

    messageObject.PartitionKey = messageObject.from;
    messageObject.RowKey = moment(message.ts).utc().format();

    messageObject.body = JSON.stringify(messageObject.body);
    messageObject.tags = JSON.stringify(messageObject.tags);
    messageObject.response_to = JSON.stringify(messageObject.response_to);
    messageObject.visible_to = JSON.stringify(messageObject.visible_to);

    this.azureTableService.insertEntity(TABLE_NAME, messageObject, callback);
};

module.exports = AzureArchiveProvider;
{'fraction_non_alphanumeric': 0.09506813757300454, 'fraction_numerical': 0.0, 'mean_word_length': 4.940269749518304, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3785551', 'n_tokens_mistral': 891, 'n_tokens_neox': 865, 'n_words': 158}