<commit_before><h1>Datasets</h1>

<p><%= link_to("Add a Dataset", deposits_path(:anchor => 'add_dataset')) %></p>

<% unless @deposits == [] %>
    <p>Listing <%= @deposits['docs'].length %> dataset<% unless @deposits['docs'].length == 1 %>s<% end %> (<%= @deposits['numFound'] %> in total)
    <% # present pagination links to each page of results
       if (@deposits['numFound']/@results_per_page.to_f).ceil > 1 then %>
         Pages: 
    <%   for i in 1..(@deposits['numFound']/@results_per_page.to_f).ceil
           if @current_page != i %>
             <%= link_to i, params.merge(:page => i) %>
    <%     else %>
             <strong><%= i %></strong>
    <%     end 
         end      
       end %>
    </p>

    <% # present an up/down arrow next to column name when column is sorted
       down_arrow = "&#9660;"
       up_arrow = "&#9650;"
       access_arrow = if params[:sort] == "access" then if params[:sort_order] == "asc" then up_arrow else down_arrow end else "" end 
       created_arrow = if params[:sort] == "created" then if params[:sort_order] == "asc" then up_arrow else down_arrow end else "" end
       available_arrow = if params[:sort] == "available" then if params[:sort_order] == "asc" then up_arrow else down_arrow end else "" end
    %>
    <table class="table-striped table-bordered table">
      <thead>
      <tr>
        <th style="width:20%">Dataset</th>
        <th style="width:5%"><%= link_to "Access", params.merge(:sort => "access").merge(:sort_order => if params[:sort] == "access" and params[:sort_order] == "asc" then "desc" else "asc" end).except(:page, :refresh) %>&nbsp;<%= access_arrow.html_safe %></th>
        <th style="width:5%"><%= link_to "Created (PURE)", params.merge(:sort => "created").merge(:sort_order => if params[:sort] == "created" and params[:sort_order] == "asc" then "desc" else "asc" end).except(:page, :refresh) %>&nbsp;<%= created_arrow.html_safe %></th>
        <th style="width:5%"><%= link_to "Date Available", params.merge(:sort => "available").merge(:sort_order => if params[:sort] == "available" and params[:sort_order] == "asc" then "desc" else "asc" end).except(:page, :refresh) %>&nbsp;<%= available_arrow.html_safe %></th>
        <th style="width:15%">Status</th>
        <th style="width:10%">AIP</th>
        <th style="width:10%">DIP</th>

        <th style="width:20%">Notes</th>

      </tr>
      </thead>

      <tbody>
      <% @deposits['docs'].each do |upload| %>
          <tr>
            <td>
              <strong>PURE UUID:</strong> <%= upload['pure_uuid_tesim'][0] %><br/>
              <strong>Title:</strong>  <%= upload['title_tesim'][0] %><br/>
              <% unless upload['creator_value_ssim'].nil? %>
                  <strong>Creator:</strong>
                  <% upload['creator_value_ssim'].each do |i| %>
                      <%= i %>;&nbsp;
                  <% end %>
                  <br/>
              <% end %>
              <strong>Managing Org:</strong>
              <% unless upload['managing_organisation_value_ssim'].nil? %>
                  <% upload['managing_organisation_value_ssim'].each do |i| %>
                      <%= i %>
                  <% end %>
              <% end %>
              <br/>
              <% unless upload['doi_tesim'].nil? %>
                  <strong>DOI:</strong>

                  <% upload['doi_tesim'].each do |doi| %>
                      <% if check_doi(doi) %>
                          <%= render 'shared/tick' %>
                      <% end %>
                      <%= link_to doi %>
                  <% end %>
                  <br/>
              <% end %>

              <% unless upload['pure_link_tesim'].nil? %>
                  <strong>Links:</strong>
                  <% upload['pure_link_tesim'].each do |link| %>
                      <%= link_to link %>;&nbsp;
                  <% end %>
                  <br/>
              <% end %>
              <% unless upload['wf_status_tesim'] and (upload['wf_status_tesim'].include? 'nodata-external' or upload['wf_status_tesim'].include? 'nodata-dept') %>
                  <strong>Deposit URL:</strong><br/>
                  <%= link_to 'http://researchdata.york.ac.uk/deposits/' + upload['id'], 'deposits/' + upload['id'] %>
                  <br/>
                  <strong>Request URL: </strong><br/>
                  <%= link_to 'http://researchdata.york.ac.uk/datasets/' + upload['id'], 'datasets/' + upload['id'] %>
              <% end %>
            </td>
            <td>

              <%= upload['dc_access_rights_tesim'][0] %>
              <% if upload['dc_access_rights_tesim'][0] == 'Embargoed' %>
                  <br/> (check PURE for embargo length)
              <% end %>

            </td>
            <td><%= DateTime.parse(upload['pure_creation_tesim'][0]).strftime("%d/%m/%Y") rescue upload['pure_creation_tesim'][0] rescue nil %></td>
            <td><%= DateTime.parse(upload['date_available_tesim'][0]).strftime("%d/%m/%Y") rescue upload['date_available_tesim'][0] rescue nil %></td>

            <% aip_list = aips(upload['id']) %>
            <% dip_list = dips(upload['id']) %>
            <% aip = get_aip(upload['id']) %>
            <% dip = get_dip(upload['id']) %>

            <td>
              <% if upload['wf_status_tesim'].nil? and (aip.nil? or aip.aip_status.empty?) and (dip.nil? or dip.dip_status.empty?) %>
                  <%= render 'shared/alert' %>
                  New Dataset<br/>
              <% elsif aip != nil and aip.aip_status == 'UPLOADED' %>
                  <%= render 'shared/tick' %>
                  Upload Complete<br/>
              <% elsif upload['wf_status_tesim'] != nil and (upload['wf_status_tesim'].include? 'nodata-dept' or upload['wf_status_tesim'].include? 'nodata-external') %>
                  <%= render 'shared/tick' %>
                  No Upload Needed<br/>
              <% elsif upload['wf_status_tesim'] != nil and (aip.nil? or aip.aip_status.empty? or aip.aip_status != 'UPLOADED') %>
                  <%= render 'shared/alert' %>
                  In Progress<br/>
              <% end %>
              <% if upload['doi_tesim'].nil? %>
                  <%= render 'shared/cross' %>
                  No DOI<br/>
              <% else %>
                  <%= render 'shared/tick' %>
                  DOI Created<br/>
              <% end %>
              <%
                @deposit = Deposit.new
                @deposit.id = upload['id']
                @deposit.status = upload['wf_status_tesim']
                unless upload['retention_policy_tesim'].nil?
                  @deposit.retention_policy = upload['retention_policy_tesim'][0]
                end
                unless upload['restriction_note_tesim'].nil?
                  @deposit.notes = upload['restriction_note_tesim']
                end
              %>
              <div id="<%= upload['id'] %>">
                <%= render partial: 'status', object: @deposit %>
              </div>
            </td>
            <td>
              <% if upload['wf_status_tesim'] != nil and (upload['wf_status_tesim'].include? 'nodata-external' or upload['wf_status_tesim'].include? 'nodata-deptl') %>
                  N/A
              <% else %>
              <% if aip_list.size != 0 %>
                  <%= render 'shared/tick' %> Deposited <br/>
                  <% if aip.aip_status == 'UPLOADED' %>
                      <%= render 'shared/tick' %> Stored <br/>
                  <% elsif aip.aip_status == 'ERROR' or aip.aip_status == 'FAILED' %>
                      <%= render 'shared/cross' %>
                      <%= aip.aip_status %> <br/>
                  <% else %>
                      <%= render 'shared/alert' %>
                      In Progress
                  <% end %>
                  <br/>
                  <%= aip_list.size %> aip<% unless aip_list.size < 2 %>s<% end %> deposited <br/>
                  <% aip_list.each do |aip| %>
                      <%= aip %> <br/>
                  <% end %>
              <% else %>
                  <%= render 'shared/cross' %> Deposited <br/><br/>
              <% end %>
              <% end %>
            </td>
            <td>
              <% if upload['wf_status_tesim'] != nil and (upload['wf_status_tesim'].include? 'nodata-external' or upload['wf_status_tesim'].include? 'nodata-deptl') %>
                N/A
              <% else %>

              <% if dip_list.size > 0 %>
                  <% unless dip.requestor_email.size == 0 %>
                      <%= render 'shared/tick' %> Requested </br>
                      <% if dip.dip_status == 'APPROVE' %>
                          <%= render 'shared/tick' %> Request Approved </br>
                          <%= render 'shared/cross' %> Not Available </br>
                      <% elsif dip.dip_status == 'UPLOADED' %>
                          <%= render 'shared/tick' %> Available </br>
                      <% else %>
                          <%= render 'shared/alert' %> Awaiting Approval </br>
                      <% end %>
                  <% end %>
                  <br/>
                  <%= dip_list.size %> aip<% unless dip_list.size < 2 %>s<% end %> created<br/>
                  <% dip_list.each do |dip| %>
                      <%= dip.id %><br/>
                      <% if !(dip.requestor_email.to_a - ["removed"]).empty? %>
                        requested by <%= (dip.requestor_email.to_a - ["removed"]).join(", ") %> <br/>
                      <% end %>
                      <% if dip.aip_status == 'UPLOADED' and dip.dip_status.nil? %>
                          <%= link_to 'Approve', '/reingest/' + upload['id'] %>
                      <% elsif dip.aip_status.nil? or dip.aip_status != 'UPLOADED' %>
                          Waiting for AIP upload
                      <% elsif dip.dip_status == 'UPLOADED' %>
                          <%= dip.dip_status %>
                          <br/><br/><commit_msg>changed wording in AIP and DIP column so that they display 'AIP' and 'DIP' rather than 'aip'<commit_after><h1>Datasets</h1>

<p><%= link_to("Add a Dataset", deposits_path(:anchor => 'add_dataset')) %></p>

<% unless @deposits == [] %>
    <p>Listing <%= @deposits['docs'].length %> dataset<% unless @deposits['docs'].length == 1 %>s<% end %> (<%= @deposits['numFound'] %> in total)
    <% # present pagination links to each page of results
       if (@deposits['numFound']/@results_per_page.to_f).ceil > 1 then %>
         Pages: 
    <%   for i in 1..(@deposits['numFound']/@results_per_page.to_f).ceil
           if @current_page != i %>
             <%= link_to i, params.merge(:page => i) %>
    <%     else %>
             <strong><%= i %></strong>
    <%     end 
         end      
       end %>
    </p>

    <% # present an up/down arrow next to column name when column is sorted
       down_arrow = "&#9660;"
       up_arrow = "&#9650;"
       access_arrow = if params[:sort] == "access" then if params[:sort_order] == "asc" then up_arrow else down_arrow end else "" end 
       created_arrow = if params[:sort] == "created" then if params[:sort_order] == "asc" then up_arrow else down_arrow end else "" end
       available_arrow = if params[:sort] == "available" then if params[:sort_order] == "asc" then up_arrow else down_arrow end else "" end
    %>
    <table class="table-striped table-bordered table">
      <thead>
      <tr>
        <th style="width:20%">Dataset</th>
        <th style="width:5%"><%= link_to "Access", params.merge(:sort => "access").merge(:sort_order => if params[:sort] == "access" and params[:sort_order] == "asc" then "desc" else "asc" end).except(:page, :refresh) %>&nbsp;<%= access_arrow.html_safe %></th>
        <th style="width:5%"><%= link_to "Created (PURE)", params.merge(:sort => "created").merge(:sort_order => if params[:sort] == "created" and params[:sort_order] == "asc" then "desc" else "asc" end).except(:page, :refresh) %>&nbsp;<%= created_arrow.html_safe %></th>
        <th style="width:5%"><%= link_to "Date Available", params.merge(:sort => "available").merge(:sort_order => if params[:sort] == "available" and params[:sort_order] == "asc" then "desc" else "asc" end).except(:page, :refresh) %>&nbsp;<%= available_arrow.html_safe %></th>
        <th style="width:15%">Status</th>
        <th style="width:10%">AIP</th>
        <th style="width:10%">DIP</th>

        <th style="width:20%">Notes</th>

      </tr>
      </thead>

      <tbody>
      <% @deposits['docs'].each do |upload| %>
          <tr>
            <td>
              <strong>PURE UUID:</strong> <%= upload['pure_uuid_tesim'][0] %><br/>
              <strong>Title:</strong>  <%= upload['title_tesim'][0] %><br/>
              <% unless upload['creator_value_ssim'].nil? %>
                  <strong>Creator:</strong>
                  <% upload['creator_value_ssim'].each do |i| %>
                      <%= i %>;&nbsp;
                  <% end %>
                  <br/>
              <% end %>
              <strong>Managing Org:</strong>
              <% unless upload['managing_organisation_value_ssim'].nil? %>
                  <% upload['managing_organisation_value_ssim'].each do |i| %>
                      <%= i %>
                  <% end %>
              <% end %>
              <br/>
              <% unless upload['doi_tesim'].nil? %>
                  <strong>DOI:</strong>

                  <% upload['doi_tesim'].each do |doi| %>
                      <% if check_doi(doi) %>
                          <%= render 'shared/tick' %>
                      <% end %>
                      <%= link_to doi %>
                  <% end %>
                  <br/>
              <% end %>

              <% unless upload['pure_link_tesim'].nil? %>
                  <strong>Links:</strong>
                  <% upload['pure_link_tesim'].each do |link| %>
                      <%= link_to link %>;&nbsp;
                  <% end %>
                  <br/>
              <% end %>
              <% unless upload['wf_status_tesim'] and (upload['wf_status_tesim'].include? 'nodata-external' or upload['wf_status_tesim'].include? 'nodata-dept') %>
                  <strong>Deposit URL:</strong><br/>
                  <%= link_to 'http://researchdata.york.ac.uk/deposits/' + upload['id'], 'deposits/' + upload['id'] %>
                  <br/>
                  <strong>Request URL: </strong><br/>
                  <%= link_to 'http://researchdata.york.ac.uk/datasets/' + upload['id'], 'datasets/' + upload['id'] %>
              <% end %>
            </td>
            <td>

              <%= upload['dc_access_rights_tesim'][0] %>
              <% if upload['dc_access_rights_tesim'][0] == 'Embargoed' %>
                  <br/> (check PURE for embargo length)
              <% end %>

            </td>
            <td><%= DateTime.parse(upload['pure_creation_tesim'][0]).strftime("%d/%m/%Y") rescue upload['pure_creation_tesim'][0] rescue nil %></td>
            <td><%= DateTime.parse(upload['date_available_tesim'][0]).strftime("%d/%m/%Y") rescue upload['date_available_tesim'][0] rescue nil %></td>

            <% aip_list = aips(upload['id']) %>
            <% dip_list = dips(upload['id']) %>
            <% aip = get_aip(upload['id']) %>
            <% dip = get_dip(upload['id']) %>

            <td>
              <% if upload['wf_status_tesim'].nil? and (aip.nil? or aip.aip_status.empty?) and (dip.nil? or dip.dip_status.empty?) %>
                  <%= render 'shared/alert' %>
                  New Dataset<br/>
              <% elsif aip != nil and aip.aip_status == 'UPLOADED' %>
                  <%= render 'shared/tick' %>
                  Upload Complete<br/>
              <% elsif upload['wf_status_tesim'] != nil and (upload['wf_status_tesim'].include? 'nodata-dept' or upload['wf_status_tesim'].include? 'nodata-external') %>
                  <%= render 'shared/tick' %>
                  No Upload Needed<br/>
              <% elsif upload['wf_status_tesim'] != nil and (aip.nil? or aip.aip_status.empty? or aip.aip_status != 'UPLOADED') %>
                  <%= render 'shared/alert' %>
                  In Progress<br/>
              <% end %>
              <% if upload['doi_tesim'].nil? %>
                  <%= render 'shared/cross' %>
                  No DOI<br/>
              <% else %>
                  <%= render 'shared/tick' %>
                  DOI Created<br/>
              <% end %>
              <%
                @deposit = Deposit.new
                @deposit.id = upload['id']
                @deposit.status = upload['wf_status_tesim']
                unless upload['retention_policy_tesim'].nil?
                  @deposit.retention_policy = upload['retention_policy_tesim'][0]
                end
                unless upload['restriction_note_tesim'].nil?
                  @deposit.notes = upload['restriction_note_tesim']
                end
              %>
              <div id="<%= upload['id'] %>">
                <%= render partial: 'status', object: @deposit %>
              </div>
            </td>
            <td>
              <% if upload['wf_status_tesim'] != nil and (upload['wf_status_tesim'].include? 'nodata-external' or upload['wf_status_tesim'].include? 'nodata-deptl') %>
                  N/A
              <% else %>
              <% if aip_list.size != 0 %>
                  <%= render 'shared/tick' %> Deposited <br/>
                  <% if aip.aip_status == 'UPLOADED' %>
                      <%= render 'shared/tick' %> Stored <br/>
                  <% elsif aip.aip_status == 'ERROR' or aip.aip_status == 'FAILED' %>
                      <%= render 'shared/cross' %>
                      <%= aip.aip_status %> <br/>
                  <% else %>
                      <%= render 'shared/alert' %>
                      In Progress
                  <% end %>
                  <br/>
                  <%= aip_list.size %> AIP<% unless aip_list.size < 2 %>s<% end %> deposited <br/>
                  <% aip_list.each do |aip| %>
                      <%= aip %> <br/>
                  <% end %>
              <% else %>
                  <%= render 'shared/cross' %> Deposited <br/><br/>
              <% end %>
              <% end %>
            </td>
            <td>
              <% if upload['wf_status_tesim'] != nil and (upload['wf_status_tesim'].include? 'nodata-external' or upload['wf_status_tesim'].include? 'nodata-deptl') %>
                N/A
              <% else %>

              <% if dip_list.size > 0 %>
                  <% unless dip.requestor_email.size == 0 %>
                      <%= render 'shared/tick' %> Requested </br>
                      <% if dip.dip_status == 'APPROVE' %>
                          <%= render 'shared/tick' %> Request Approved </br>
                          <%= render 'shared/cross' %> Not Available </br>
                      <% elsif dip.dip_status == 'UPLOADED' %>
                          <%= render 'shared/tick' %> Available </br>
                      <% else %>
                          <%= render 'shared/alert' %> Awaiting Approval </br>
                      <% end %>
                  <% end %>
                  <br/>
                  <%= dip_list.size %> DIP<% unless dip_list.size < 2 %>s<% end %> created<br/>
                  <% dip_list.each do |dip| %>
                      <%= dip.id %><br/>
                      <% if !(dip.requestor_email.to_a - ["removed"]).empty? %>
                        requested by <%= (dip.requestor_email.to_a - ["removed"]).join(", ") %> <br/>
                      <% end %>
                      <% if dip.aip_status == 'UPLOADED' and dip.dip_status.nil? %>
                          <%= link_to 'Approve', '/reingest/' + upload['id'] %>
                      <% elsif dip.aip_status.nil? or dip.aip_status != 'UPLOADED' %>
                          Waiting for AIP upload
                      <% elsif dip.dip_status == 'UPLOADED' %>
                          <%= dip.dip_status %>
                          <br/><br/>
{'fraction_non_alphanumeric': 0.17279026870731343, 'fraction_numerical': 0.003988234707612543, 'mean_word_length': 1.5820568927789935, 'pattern_counts': {'":': 0, '<': 449, '<?xml version=': 0, '>': 465, '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': '798440', 'n_tokens_mistral': 6572, 'n_tokens_neox': 5795, 'n_words': 1165}