<commit_before>function getLastEditedEvent(collection, page) {
  var pageEvents = collection.eventsByUri[page];

  var lastEditedEvent = _.chain(pageEvents)
    .filter(function (event) {
      return event.type === 'EDITED'
    })
    .sortBy(function (event) {
      return event.date;
    })
    .last()
    .value();

  return lastEditedEvent;
}

function getLastCompletedEvent(collection, page) {
   var lastCompletedEvent;

  if (collection.eventsByUri) {
    var pageEvents = collection.eventsByUri[page];
    if (pageEvents) {
      lastCompletedEvent = _.chain(pageEvents)
        .filter(function (event) {
          return event.type === 'COMPLETED'
        })
        .sortBy(function (event) {
          return event.date;
        })
        .last()
        .value();
    }
  }
  return lastCompletedEvent;
}<commit_msg>Fix for submit for approval button not always showing.  Ensure event lookup uses consistent uri format.<commit_after>function getLastEditedEvent(collection, page) {

  var uri = page;
  if (uri.charAt(0) !== '/') {
    uri = "/" + uri;
  }

  var pageEvents = collection.eventsByUri[uri];

  var lastEditedEvent = _.chain(pageEvents)
    .filter(function (event) {
      return event.type === 'EDITED'
    })
    .sortBy(function (event) {
      return event.date;
    })
    .last()
    .value();

  return lastEditedEvent;
}

function getLastCompletedEvent(collection, page) {

  var uri = page;
  if (uri.charAt(0) !== '/') {
    uri = "/" + uri;
  }

   var lastCompletedEvent;

  if (collection.eventsByUri) {
    var pageEvents = collection.eventsByUri[uri];
    if (pageEvents) {
      lastCompletedEvent = _.chain(pageEvents)
        .filter(function (event) {
          return event.type === 'COMPLETED'
        })
        .sortBy(function (event) {
          return event.date;
        })
        .last()
        .value();
    }
  }
  return lastCompletedEvent;
}
{'fraction_non_alphanumeric': 0.12906610703043023, 'fraction_numerical': 0.001049317943336831, 'mean_word_length': 2.5644859813084113, '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': '4040632', 'n_tokens_mistral': 594, 'n_tokens_neox': 586, 'n_words': 127}