Skip to content

Commit 2d729ee

Browse files
committed
See report history in genomes
1 parent 6179236 commit 2d729ee

4 files changed

Lines changed: 42 additions & 10 deletions

File tree

app/helpers/application_helper.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ def cannonical_url
33
url_for(only_path: false, protocol: 'https', host: 'registry.seqco.de')
44
end
55

6+
def report_history(obj, text: 'Report history')
7+
id = modal('Report history') do
8+
obj.reports.map do |report|
9+
content_tag(:div, class: 'border') do
10+
time_ago_with_date(report.created_at, true) +
11+
report.html.html_safe
12+
end
13+
end.inject(:+)
14+
end
15+
modal_button(id, class: 'btn btn-primary btn-sm') do
16+
fa_icon('archive') + ' ' + text
17+
end
18+
end
19+
620
def list_preference
721
cookies[:list] || 'cards'
822
end

app/models/genome/external_resources.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def reload_source_json!
5050
# Find BioSample accession linked to the SRA entry +acc+ and return as
5151
# String (or +nil+)
5252
def external_sra_to_biosample(acc)
53-
SequencingExperiment.by_sra(acc).try(:biosample_accession)
53+
sr = SequencingExperiment.by_sra(acc)
54+
ephemeral_report << sr.try(:ephemeral_report)
55+
sr.try(:biosample_accession)
5456
end
5557

5658
##
@@ -64,7 +66,8 @@ def external_biosample_to_sra(acc)
6466
ng = Nokogiri::XML(body)
6567
ng.xpath('//result/entries/entry').map do |exp|
6668
sra_acc = exp['acc'] || exp['id'] or next
67-
SequencingExperiment.find_or_create_by(sra_accession: sra_acc)
69+
sr = SequencingExperiment.find_or_create_by(sra_accession: sra_acc)
70+
ephemeral_report << sr.try(:ephemeral_report)
6871
end
6972
end
7073

app/views/genomes/_curator.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<dl name="curator" class="main-section name-details actions-section">
33
<h2>Curator Actions</h2>
44
<dd class="pt-2">
5+
<%= report_history(@genome) %>
6+
&raquo; See the logs from automated tasks
7+
<hr/>
58
<%= link_to(
69
update_external_genome_url(@genome),
710
method: :post, class: 'btn btn-primary btn-sm'

lib/ephemeral_report.rb

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@ def <<(message)
1717
end
1818
end
1919

20-
def to_s
21-
@messages.map(&:to_s).join("\n")
20+
def title_message
21+
EphemeralMessage.new(obj.qualified_id, type: :section)
2222
end
2323

24-
def to_html
25-
@messages.map(&:to_html).join("\n")
24+
def end_messsage
25+
EphemeralMessage.new('Report end for %s' % obj.qualified_id)
26+
end
27+
28+
def to_s(section: false)
29+
y = @messages.map(&:to_s).join("\n")
30+
y = title_message.to_s + "\n" + y if section
31+
y + "\n" + end_message.to_s
32+
end
33+
34+
def to_html(section: false)
35+
y = @messages.map(&:to_html).join("\n")
36+
y = title_message.to_html + "\n" + y if section
37+
y.html_safe + "\n" + end_message.to_html
2638
end
2739

2840
def save
@@ -47,15 +59,15 @@ def initialize(message, type: :info)
4759

4860
def to_s
4961
@message.is_a?(EphemeralReport) ?
50-
@message.to_s :
62+
@message.to_s(section: true) :
5163
'%s: [%s] %s' % [@type.to_s.upcase, @timestamp.to_s, @message.to_s]
5264
end
5365

5466
def to_html
5567
@message.is_a?(EphemeralReport) ?
56-
@message.to_html :
57-
'<div class="%s"><span class="text-muted">[%s]</span> %s</div>' % [
58-
html_class, @timestamp.to_s, @message.to_s
68+
@message.to_html(section: true) :
69+
'<div class="%s %s"><span class="text-muted">[%s]</span> %s</div>' % [
70+
'report-message', html_class, @timestamp.to_s, @message.to_s
5971
]
6072
end
6173

0 commit comments

Comments
 (0)