steem-third-party/ganymede

View on GitHub
app/views/follows/index.html.haml

Summary

Maintainability
Test Coverage
%div.float-right
  = form_tag follows_path, method: :get do
    = select_tag :op, options_for_select([['Followed by:', 'followings'], ['Following:', 'followers'], ['Ignored by:', 'ignores'], ['Ignoring:', 'ignoring']], @op)
    = text_field_tag :account, @account, placeholder: 'User Name'
    = select_tag :activity_after, activity_options_for_select('activity after', params[:activity_after])
    = select_tag :activity_before, activity_options_for_select('activity before', params[:activity_before])
    = submit_tag 'Query', class: 'btn btn-primary'
%br
%hr

  .jumbotron
    %h4
      #{pluralize(@follows.size, 'users')} 
      - if @op == 'followings'
        followed by
        = @account
      - elsif @op == 'followers'
        following
        = @account
      - elsif @op == 'ignores'
        ignored by
        = @account
      - elsif @op == 'ignoring'
        ignoring
        = @account
      - if !!params[:activity_after].presence
        having activity after
        = time_ago_in_words @activity_after
        ago
      - if !!params[:activity_before].presence
        having activity before
        = time_ago_in_words @activity_before
        ago
      = surround '(totalling: ', ')' do
        = "%.1f" % (@total_author_vests / 1000000.0)
        = steemit? ? 'MVESTS' : 'MGESTS'

- if !!@follows && @follows.any?
  %table.table-sm.table-striped.table-bordered
    %thead
      %tr
      %th ID
      %th Last Post
      %th Last Vote
      - if (include_created_at = @accounts.map { |a| a.last.json_metadata['created_at'] }.reject(&:nil?).any?)
        %th Created At
      - if (include_ico = @accounts.map { |a| a.last.json_metadata['ico_address'] }.reject(&:nil?).any?)
        %th ICO
      - if (include_profile = @accounts.map { |a| a.last.json_metadata['profile'] }.reject(&:nil?).any?)
        %th Has Profile
    %tbody
      - @follows.each do |follow|
        - account = @accounts[follow]
        - json_metadata = account.json_metadata.present? ? JSON[account.json_metadata] : {} rescue {}
        - json_metadata = json_metadata.class == Hash ? json_metadata : {}
        %tr
          %td= link_to follow, "#{site_prefix}/@#{follow}"
          %td
            - if account.last_post == '1970-01-01T00:00:00'
              %i never
            - else
              = time_ago_in_words Time.parse(account.last_post + 'Z')
              ago
          %td
            - if account.last_vote_time == '1970-01-01T00:00:00'
              %i never
            - else
              = time_ago_in_words Time.parse(account.last_vote_time + 'Z')
              ago
          - if include_created_at
            %td= json_metadata['created_at']
          - if include_created_at
            %td= !!json_metadata['ico_address'] ? '√' : ''
          - if include_profile
            %td= !!json_metadata['profile'] ? '√' : ''
          
- if @op == 'followers' || @op == 'followings'
  See:
  = link_to 'How to List All Followers in Ruby', 'https://steemit.com/radiator/@inertia/how-to-list-all-followers-in-ruby'
  
- if @op == 'ignores' || @op == 'ignoring'
  See:
  = link_to 'How to List All Ignores (Mutes) in Ruby', 'https://steemit.com/radiator/@inertia/how-to-list-all-ignores-mutes-in-ruby'