<commit_before><template>
  <div class="list mediaList">
    <div class="item" v-for="m in filteredMedia">
      <div class="item-content">
        <media-list-item :m="m"></media-list-item>
      </div>
    </div>
  </div>
</template>

<script>
  import MediaListItem from 'components/MediaListItem.vue'

  export default {
    data () {
      return {

      }
    },
    components: {
      MediaListItem
    },
    computed: {
      filteredMedia: function () {
        if (this.searchQuery) {
          let searchLower = this.searchQuery.toLowerCase()
          return this.mediaItems.filter(function (m) {
            let title = ''
            let am
            if (m['media-data'] !== undefined) {
              am = m['media-data']['alexandria-media']
            }
            if (m['oip-041'] !== undefined) {
              title = m.title
            }
            if (am !== undefined) {
              title = am.info.title
            }
            return title.toLowerCase().indexOf(searchLower) !== -1
          })
        }
        return this.mediaItems
      }
    },
    props: ['searchQuery', 'mediaItems']
  }
</script>

<style>
  .mediaList {
    width: 80%;
    margin: auto;
  }
</style>
<commit_msg>Sort by timestamp<commit_after><template>
  <div class="list mediaList">
    <div class="item" v-for="m in filteredMedia">
      <div class="item-content">
        <media-list-item :m="m"></media-list-item>
      </div>
    </div>
  </div>
</template>

<script>
  import MediaListItem from 'components/MediaListItem.vue'

  export default {
    data () {
      return {

      }
    },
    components: {
      MediaListItem
    },
    computed: {
      sortedMedia: function () {
        let dc = deepCopy(this.mediaItems)
        return dc.sort(function (a, b) {
          let tsa = 0, tsb = 0

          if (a['media-data'] !== undefined) {
            let ama = a['media-data']['alexandria-media']
            if (ama !== undefined) {
              tsa = ama.timestamp
            }
          }
          if (a['oip-041'] !== undefined) {
            tsa = a['oip-041'].artifact.timestamp
          }
          if (b['media-data'] !== undefined) {
            let amb = b['media-data']['alexandria-media']
            if (amb !== undefined) {
              tsb = amb.timestamp
            }
          }
          if (b['oip-041'] !== undefined) {
            tsb = b['oip-041'].artifact.timestamp
          }

          if (tsa >= 10000000000) {
            tsa = tsa / 1000
          }
          if (tsb >= 10000000000) {
            tsb = tsb / 1000
          }

          return tsb - tsa
        })
      },
      filteredMedia: function () {
        if (this.searchQuery) {
          let searchLower = this.searchQuery.toLowerCase()
          return this.sortedMedia.filter(function (m) {
            let title = ''
            let am
            if (m['media-data'] !== undefined) {
              am = m['media-data']['alexandria-media']
            }
            if (m['oip-041'] !== undefined) {
              title = m.title
            }
            if (am !== undefined) {
              title = am.info.title
            }
            return title.toLowerCase().indexOf(searchLower) !== -1
          })
        }
        return this.sortedMedia
      }
    },
    props: ['searchQuery', 'mediaItems']
  }

  function deepCopy (o) {
    let copy = o, k

    if (o && typeof o === 'object') {
      copy = Object.prototype.toString.call(o) === '[object Array]' ? [] : {}
      for (k in o) {
        if (o.hasOwnProperty(k)) {
          copy[k] = deepCopy(o[k])
        }
      }
    }

    return copy
  }
</script>

<style>
  .mediaList {
    width: 80%;
    margin: auto;
  }
</style>

{'fraction_non_alphanumeric': 0.1497584541062802, 'fraction_numerical': 0.015029522275899088, 'mean_word_length': 1.5080753701211305, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3282157', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1131, 'n_words': 237}