<commit_before>###
Plugin which shows SKU reviews for a given product
###

## Helpers

attachEvent = (element, event, handler) ->
  return element.addEventListener event, handler, false  if element.addEventListener
  element.attachEvent "on#{event}", handler if element.attachEvent

format_1_decimal = (num, translate_decimal = true) ->
  decimal_point = if translate_decimal then '@@translations.partner_sku_reviews.decimal_point' else '.'
  num.toFixed(1).replace('.', decimal_point)

## Reusable template fragments

# "1 star", "2 stars", "2.3 stars" etc...
starText = (star_score, fraction = false, translate_decimal = true) ->
  star_score = format_1_decimal(star_score, translate_decimal) if fraction
  star_score + if !fraction && star_score == 1
                 ' @@translations.partner_sku_reviews.star'
               else
                 ' @@translations.partner_sku_reviews.stars'

stars = (reviewscore, reviews_count, fraction = false) ->
  starsWidth = 0;
  if reviewscore
    starsWidth = (reviewscore * 20).toFixed(1)
    title = starText(reviewscore, fraction)

  if reviews_count
    title += " @@translations.partner_sku_reviews.from #{reviews_count} "
    title += if reviews_count == 1
               ' @@translations.partner_sku_reviews.user_from '
             else
               '@@translations.partner_sku_reviews.users_from'

  """
    <div class="sa-star-rating" title="#{title}">
      <div class="sa-star-rating-wrapper">
        <div class="sa-actual-star-rating" style="width: #{starsWidth}%"></div>
      </div>
    </div>
  """

# rating value and stars
starRating = (reviewscore, reviews_count, translate_decimal=true) -> """
    <div class="sa-rating-value">#{format_1_decimal(reviewscore, translate_decimal)}</div>
    #{stars(reviewscore, reviews_count, true)}
    <div class="sa-reviews-count-compact">#{reviews_count}</div>
  """<commit_msg>Remove redundant spaces in Partner SKU Reviews<commit_after>###
Plugin which shows SKU reviews for a given product
###

## Helpers

attachEvent = (element, event, handler) ->
  return element.addEventListener event, handler, false  if element.addEventListener
  element.attachEvent "on#{event}", handler if element.attachEvent

format_1_decimal = (num, translate_decimal = true) ->
  decimal_point = if translate_decimal then '@@translations.partner_sku_reviews.decimal_point' else '.'
  num.toFixed(1).replace('.', decimal_point)

## Reusable template fragments

# "1 star", "2 stars", "2.3 stars" etc...
starText = (star_score, fraction = false, translate_decimal = true) ->
  star_score = format_1_decimal(star_score, translate_decimal) if fraction
  star_score + if !fraction && star_score == 1
                 ' @@translations.partner_sku_reviews.star'
               else
                 ' @@translations.partner_sku_reviews.stars'

stars = (reviewscore, reviews_count, fraction = false) ->
  starsWidth = 0;
  if reviewscore
    starsWidth = (reviewscore * 20).toFixed(1)
    title = starText(reviewscore, fraction)

  if reviews_count
    title += " @@translations.partner_sku_reviews.from #{reviews_count} "
    title += if reviews_count == 1
               '@@translations.partner_sku_reviews.user_from'
             else
               '@@translations.partner_sku_reviews.users_from'

  """
    <div class="sa-star-rating" title="#{title}">
      <div class="sa-star-rating-wrapper">
        <div class="sa-actual-star-rating" style="width: #{starsWidth}%"></div>
      </div>
    </div>
  """

# rating value and stars
starRating = (reviewscore, reviews_count, translate_decimal=true) -> """
    <div class="sa-rating-value">#{format_1_decimal(reviewscore, translate_decimal)}</div>
    #{stars(reviewscore, reviews_count, true)}
    <div class="sa-reviews-count-compact">#{reviews_count}</div>
  """
{'fraction_non_alphanumeric': 0.13431656570977088, 'fraction_numerical': 0.007374242823281538, 'mean_word_length': 3.8015170670037928, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 33, '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': '2750559', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1181, 'n_words': 250}