QutBioacoustics/baw-server

View on GitHub
app/views/sites/orphans.html.haml

Summary

Maintainability
Test Coverage
- content_for :title, 'Site Management'

= render partial: 'shared/admin/sidebar_home'

- content_for :right_sidebar do
  = render partial: 'shared/sidebar_metadata_heading', locals: {title: 'Admin', icon: 'cog'}

- if @sites.empty?
  %p
    No orphan sites.
- else
  %p
    There are #{@sites.count} orphan sites. Sites that are not in a project cannot be accessed.
  %p
    To assign orphan sites to a project, go to the project's detail page and click on 'Edit Sites' in the list of links on the left.

    - NaturalSort.sort(@sites, :name).each do |site|
      %h4
        = site.name
        - ar_max = site.audio_recordings.maximum('recorded_date')
        - display_max = ar_max.nil? ? 'unknown' : ar_max.to_formatted_s(:db)
        - ar_min = site.audio_recordings.minimum('recorded_date')
        - display_min = ar_min.nil? ? 'unknown' : ar_min.to_formatted_s(:db)
        - ar_ids = site.audio_recordings.pluck(:id)
        - total_annotations = AudioEvent.where(audio_recording_id: ar_ids).count
        %small
          #{site.audio_recordings.count} audio recordings between #{display_min} to #{display_max} with #{total_annotations} annotations
      %ul.nav.nav-pills
        - site.audio_recordings.each do |audio_recording|
          %li= link_to audio_recording.id, make_listen_path(audio_recording)