steem-third-party/ganymede

View on GitHub
app/views/discussions/other_promoted.html.haml

Summary

Maintainability
Test Coverage
= content_for :head, auto_discovery_link_tag(:atom, discussions_url(other_promoted: 'true', min_promotion_amount: @min_promotion_amount, format: :atom))
= content_for :head, auto_discovery_link_tag(:rss, discussions_url(other_promoted: 'true', min_promotion_amount: @min_promotion_amount, format: :rss))

= render partial: 'nav' unless action_name == 'card'

.card.border-top-0{style: 'padding-top: 0'}
  .card-block
    .row
      .col-md-12

        %div.float-right
          = form_tag discussions_path, method: :get, class: 'form-inline' do
            = hidden_field_tag :other_promoted, true
            .row
              .form-group
                %label{for: :min_promotion_amount} Minimum Amount:
                = number_field_tag :min_promotion_amount, @min_promotion_amount, class: 'form-control form-control-sm', style: 'width: 96px'
                   
              .form-group
                = submit_tag 'Query', class: 'btn btn-primary'

        %br
        %br

        .jumbotron
          %h4
            These posts have been promoted by someone other than the author … totalling:
            = discussion_amounts_total
              
        %small
          %ul
            - @discussions.group_by{ |d| group_pattern(d) }.sort_by{ |d| d.last.last[:timestamp] }.each do |group|
              - key = group.first
              - duration = key.first
              - from = key.second
              - amount = key.last
              - discussion = group.last.last
              - title = discussion[:slug].split('/')[1..-1].join(' ')
              - title = title.titleize
              %li
                #{duration} ago, #{link_to from, "#{site_prefix}/@#{from}"}
                %font.reputation= discussion[:from_reputation]
                paid #{amount}
                - if group.last.size == 1
                  \-
                  = link_to title, "#{site_prefix}#{discussion[:url]}"
                  by
                  = link_to discussion[:author], "#{site_prefix}/@#{discussion[:author]}"
                  %font.reputation= discussion[:author_reputation]
                - else
                  %ul
                    - group.last.each do |discussion|
                      %li
                        = link_to title, "#{site_prefix}#{discussion[:url]}"
                        by
                        = link_to discussion[:author], "#{site_prefix}/@#{discussion[:author]}"
                        %font.reputation= discussion[:author_reputation]

        See:
        = link_to "How to Find Post Promotions Paid by a Third Party in Ruby", "https://steemit.com/radiator/@inertia/how-to-find-post-promotions-paid-by-a-third-party-in-ruby"