<commit_before>var path = require("path");

var _ = require("lodash");
var Bacon = require("baconjs");
var colors = require("colors");
var moment = require("moment");

var Activity = require("../models/activity.js");
var AppConfig = require("../models/app_configuration.js");

var Logger = require("../logger.js");

var displayState = function(state) {
  switch(state) {
    case "OK":        return "OK       ".bold.green;
    case "FAIL":      return "FAIL     ".bold.red;
    case "CANCELLED": return "CANCELLED".bold.red;
    default:          return "UNKNOWN  ";
  }
};
var unspecifiedCommitId = "not specified                           ";

var activity = module.exports = function(api, params) {
  var alias = params.options.alias;
  var showAll = params.options["show-all"];
  var s_appData = AppConfig.getAppData(alias);

  var s_activity = s_appData.flatMapLatest(function(appData) {
    return Activity.list(api, appData.app_id, appData.org_id, showAll);
  });

  s_activity.onValue(function(deployments) {
    console.log(deployments.map(function(deployment) {
      return moment(deployment.date).format() + " - " +
             displayState(deployment.state) + " " +
             _.padRight(deployment.action, 8) + " " +
             (deployment.commit || unspecifiedCommitId) + " " +
             deployment.cause;<commit_msg>Improve activity display<commit_after>var path = require("path");

var _ = require("lodash");
var Bacon = require("baconjs");
var colors = require("colors");
var moment = require("moment");

var Activity = require("../models/activity.js");
var AppConfig = require("../models/app_configuration.js");

var Logger = require("../logger.js");

var displayState = function(state, isFirst) {
  switch(state) {
    case "OK":        return "OK         ".bold.green;
    case "FAIL":      return "FAIL       ".bold.red;
    case "CANCELLED": return "CANCELLED  ".bold.red;
    case "WIP":
      if(isFirst) {
                      return "IN PROGRESS".bold.blue;
      } else {
                      return "FAIL       ".bold.red;
      }
    default:
      Logger.warn("Unknown deployment state: " + state);
                      return "UNKNOWN    ";
  }
};
var unspecifiedCommitId = _.padRight("not specified", 40); // a git commit id is 40 chars long

var activity = module.exports = function(api, params) {
  var alias = params.options.alias;
  var showAll = params.options["show-all"];
  var s_appData = AppConfig.getAppData(alias);

  var s_activity = s_appData.flatMapLatest(function(appData) {
    return Activity.list(api, appData.app_id, appData.org_id, showAll);
  });

  s_activity.onValue(function(deployments) {
    console.log(deployments.map(function(deployment, index) {
      return moment(deployment.date).format() + " - " +
             displayState(deployment.state, index == 0) + " " +
             _.padRight(deployment.action, 8) + " " +
             (deployment.commit || unspecifiedCommitId) + " " +
             deployment.cause;
{'fraction_non_alphanumeric': 0.1459170013386881, 'fraction_numerical': 0.0023427041499330657, 'mean_word_length': 2.8518041237113403, 'pattern_counts': {'":': 7, '<': 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': '2453872', 'n_tokens_mistral': 926, 'n_tokens_neox': 898, 'n_words': 189}