<commit_before>angular.module 'jaMusic1'
  .factory 'Albums', (Common, env, $http) ->

    searchAlbums = (query = '') ->
      url = "#{env.url}#{env.version}/albums/?client_id=#{env.clientId}&namesearch=#{query}"
      $http.get(url)
      .then(Common.getSuccess)
      .catch(Common.getError)

    getAlbumTracks = (id) ->
      url = "#{env.url}#{env.version}/albums/tracks/?client_id=#{env.clientId}&id=#{id}"
      $http.get(url)
      .then(Common.getSuccess)
      .catch(Common.getError)


    factory =
      searchAlbums: searchAlbums
      getAlbumTracks: getAlbumTracks<commit_msg>Albums details cache<commit_after>angular.module 'jaMusic1'
  .factory 'Albums', (Common, env, $http, $localStorage, $q) ->
    storage = $localStorage

    searchAlbums = (query = '') ->
      url = "#{env.url}#{env.version}/albums/?client_id=#{env.clientId}&namesearch=#{query}"
      $http.get(url)
      .then(Common.getSuccess)
      .catch(Common.getError)

    getAlbumTracks = (id) ->
      cache = storage["album_#{id}"]

      if cache and cache.results.length
        defer = $q.defer()
        defer.resolve cache
        return defer.promise

      url = "#{env.url}#{env.version}/albums/tracks/?client_id=#{env.clientId}&id=#{id}"
      $http.get(url)
      .then((res) ->
        storage["album_#{id}"] = res.data
        return res.data
      )
      .catch(Common.getError)


    factory =
      searchAlbums: searchAlbums
      getAlbumTracks: getAlbumTracks
{'fraction_non_alphanumeric': 0.16859279401767505, 'fraction_numerical': 0.0013596193065941536, 'mean_word_length': 2.894179894179894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '804851', 'n_tokens_mistral': 529, 'n_tokens_neox': 500, 'n_words': 73}