Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
LocoDelAssembly committed Oct 11, 2022
2 parents cab796c + f27b57a commit e1c859e
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 98 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv

\-

## [0.29.5] - 2022-10-10

### Changed
- Changed author labels on Filter source [#3134]
- Minor changes to plots on administration activity dashboard
- Parallelize some indexing rake tasks

### Fixed
- Recent and Quick list are empty on Citation annotator [#3133]

[#3133]: https://github.com/SpeciesFileGroup/taxonworks/issues/3133
[#3134]: https://github.com/SpeciesFileGroup/taxonworks/issues/3134

## [0.29.4] - 2022-10-07
### Added
- Distribution, Material Examined sections, and zip download for paper catalog [#3098]
Expand All @@ -16,7 +29,6 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv
- Previous and next links in Matrix row coder [#3107]
- Match identifiers facet to Filter extract task [#3089]
- `Clone previous citation` to citation panels [#3097]
- Populate column button for Matrix Column Coder [#3117]
- `scientificName` is now implied in `typeStatus` when only the type of type is specified in DwC occurrences importer
- Additional DwC classification terms [#3118]

Expand Down Expand Up @@ -2966,7 +2978,8 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv

[#1532]: https://github.com/SpeciesFileGroup/taxonworks/issues/1532

[unreleased]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.29.4...development
[unreleased]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.29.5...development
[0.29.5]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.29.4...v0.29.5
[0.29.4]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.29.3...v0.29.4
[0.29.3]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.29.2...v0.29.3
[0.29.2]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.29.1...v0.29.2
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ gem 'asciidoctor', '~> 2.0'
# www
gem 'wikidata-client', '~> 0.1.0.pre.rc1', require: 'wikidata'

# Maintenance
gem 'parallel', '~> 1.22'
gem 'ruby-progressbar', '~> 1.11'

group :test, :development do
gem 'faker', '~> 2.10'
gem 'rspec-rails', '~> 5.0'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ DEPENDENCIES
paper_trail (~> 12.0)
paperclip!
paperclip-meta (~> 3.0)
parallel (~> 1.22)
parallel_tests
passenger (~> 6.0.2)
pdf-reader (~> 2.2)
Expand Down Expand Up @@ -733,6 +734,7 @@ DEPENDENCIES
rubocop-rspec (~> 2.6)
ruby-graphviz (~> 1.2.5)
ruby-prof (~> 1.2)
ruby-progressbar (~> 1.11)
ruby-units (~> 2.3.0)
rubyzip (~> 2.3.0)
sassc-rails (~> 2.1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="citation_annotator">
<FormCitation
v-model="citation"
:klass="objectType"
:submit-button="{
label: 'Save',
color: 'create'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>
<h3>Authors</h3>
<div class="field label-above">
<label>Author</label>
<label>Author as text string</label>
<input
type="text"
class="full_width"
Expand All @@ -15,7 +15,7 @@
</label>
</div>
<fieldset>
<legend>Authors</legend>
<legend>Author as role</legend>
<smart-selector
model="people"
target="Author"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ def sv_specific_relationship
true
end

def sv_not_specific_relationship
true
end

end
66 changes: 66 additions & 0 deletions app/views/administration/_users_past_day.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<div class="panel content">
<h2> Activity of past 24 hours</h2>

<% d = User.where('last_seen_at > ?', 1.day.ago).group_by_hour_of_day(:last_seen_at, format: "%H").count.sort.collect{|a,b| b} %><br>

<div style="height: 280px; width: 420px;">
<canvas id="myChart"></canvas>
</div>
</div>

<script>
const ctx = document.getElementById('myChart');
const myChart = new Chart(ctx, {
type: 'polarArea',

data: {
labels: [<%= (1..24).collect{|t| ('"' + t.to_s + '"').html_safe}.join(', ').html_safe %>],
datasets: [{
label: 'Users in past 24 hours',
data: <%= d %> ,
backgroundColor: [
'rgb(250, 250, 110)',
'rgb(228, 245, 112)',
'rgb(207, 239, 114)',
'rgb(187, 234, 118)',
'rgb(167, 227, 121)',
'rgb(148, 220, 125)',
'rgb(130, 213, 129)',
'rgb(112, 206, 133)',
'rgb(94, 198, 136)',
'rgb(77, 190, 139)',
'rgb(61, 182, 141)',
'rgb(44, 174, 143)',
'rgb(26, 165, 143)',
'rgb(2, 157, 143)',
'rgb(0, 148, 142)',
'rgb(0, 140, 139)',
'rgb(0, 131, 136)',
'rgb(0, 122, 132)',
'rgb(10, 114, 126)',
'rgb(22, 105, 120)',
'rgb(30, 97, 113)',
'rgb(36, 88, 105)',
'rgb(40, 80, 97)',
'rgb(42, 72, 88)']
}]
},
options: {
responsibe: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'left',
title: {
text: 'Hours ago',
display: true,
}
},
title: {
display: false,
}
}
},
});
</script>

52 changes: 26 additions & 26 deletions app/views/administration/user_activity.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

<%= link_to 'Back', administration_path() %>

<div class="flexbox">
<div class="item item1">
<div class="flexbox separate-bottom">

<div class="panel content separate-left">
<h2> Last 20 logins </h2>
<ol>
<% User.limit(20).order(current_sign_in_at: :desc).where('current_sign_in_at IS NOT NULL').each do |u| -%>
Expand All @@ -16,7 +17,7 @@
</ol>
</div>

<div class="item item2">
<div class="panel content separate-left">
<h2> Recently seen </h2>
<ol>
<% User.limit(20).order(last_seen_at: :desc).where('last_seen_at IS NOT NULL').each do |u| -%>
Expand All @@ -25,7 +26,8 @@
</ol>
</div>

<div class="item item3">

<div class="panel content separate-left">
<h2> Most active </h2>
<p> Estimate. If sequential requests are less than 5 minutes appart time between requests is summed to total. <p>
<ol>
Expand All @@ -38,41 +40,39 @@
</div>

<div class="simple_flexbox">
<div>
<h2> Activity today by hour</h2>
<p> For the past 24 hrs. Hours are UTC.</p>
<%= pie_chart User.where('last_seen_at > ?', 1.day.ago).group_by_hour(:last_seen_at, format: "%H").count.sort, discrete: true %>
<% days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] %>

<div class="panel content">
<h2> Active users in past </h2>
<ul>
<li> 24 hours: <%= tag.strong User.where('last_seen_at > ?', 24.hours.ago).count %></li>
<li> Week: <%= tag.strong User.where('last_seen_at > ?', 1.week.ago).count %></li>
<li> Month: <%= tag.strong User.where('last_seen_at > ?', 1.month.ago).count %></li>
<li> Half year: <%= tag.strong User.where('last_seen_at > ?', 6.months.ago).count %></li>
<li> Year: <%= tag.strong User.where('last_seen_at > ?', 1.year.ago).count %></li>
<li> 3 Years: <%= tag.strong User.where('last_seen_at > ?', 3.years.ago).count %></li>
<li> All time: <%= tag.strong User.where('last_seen_at > ?', 1000.years.ago).count %></li>
</ul>
</div>

<div>
<%= render partial: 'users_past_day' %>

<div class="panel content">
<h2> Last seen - past week </h2>
<% data = User.where('last_seen_at > ?', 1.week.ago).group_by_day_of_week(:last_seen_at, format: "%a").count %>
<% data = User.where('last_seen_at > ?', 1.week.ago).group_by_day_of_week(:last_seen_at, format: "%a").count %>
<p><%= data.values.sum %> users were seen last week.</p>
<%= column_chart data, discrete: true, ytitle: 'Count', xtitle: 'Last seen day', width: '400px' %>
</div>

<div>
<h2> All time user activity activity by last seen at per week </h2>
<p> This describes when all users were <em>last</em> active across all time. </p>
<%= column_chart User.group_by_day(:last_seen_at, format: "%a").count, xtitle: 'Day', ytitle: 'Number of users', width: '400px' %>
<%= column_chart data.to_a.sort{|a,b| days.index(a[0]) <=> days.index(b[0]) }, discrete: true, ytitle: 'Count', xtitle: 'Last seen day', width: '400px' %>
</div>
</div>

<div class="flexbox">
<div class="item item1">
<div class="panel content separate-top">
<h2> Users per project</h2>
<%= column_chart Project.joins(:users).group(:id).count.to_a.collect{|a,b| [Project.find(a).name, b] }.sort_by(&:second).reverse!, xtitle: 'Project', ytitle: 'Number of users', discrete: true, height: '400px' %>
</div>
</div>

<div class="flexbox">
<div class="item item1">
<div class="panel content separate-top">
<h2> Estimated activity per project </h2>
<p>Important: this plot is an estimate based on user activity. Active users in multiple projects will skew this estimate as their toal activity throughout is added to both projects. </p>
<%= column_chart Project.joins(:users).where('last_seen_at > ?', 1.week.ago).group(:id).sum(:time_active).to_a.collect{|a,b| [Project.find(a).name, (b.to_f / 3600.0).round(0) ]}.sort_by(&:second).reverse!, xtitle: 'Project', ytitle: 'Time active (hours)', discrete: true, height: '400px' %>
</div>
</div>




34 changes: 34 additions & 0 deletions lib/tasks/maintenance/collecting_events.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@ namespace :tw do
namespace :maintenance do
namespace :collecting_events do

# # Removed from CollectingEvent
# # @return [Boolean] always true
# # A development method only. Attempts to create a verbatim georeference for every
# # collecting event record that doesn't have one.
# # TODO: this needs to be in a curate rake task or somewhere else
# def self.update_verbatim_georeferences
# if Rails.env == 'production'
# puts "You can't run this in #{Rails.env} mode."
# exit
# end

# passed = 0
# failed = 0
# attempted = 0

# CollectingEvent.includes(:georeferences).where(georeferences: {id: nil}).each do |c|
# next if c.verbatim_latitude.blank? || c.verbatim_longitude.blank?
# attempted += 1
# g = c.generate_verbatim_data_georeference(true)
# if g.errors.empty?
# passed += 1
# puts "created for #{c.id}"
# else
# failed += 1
# puts "failed for #{c.id}, #{g.errors.full_messages.join('; ')}"
# end
# end
# puts "passed: #{passed}"
# puts "failed: #{failed}"
# puts "attempted: #{attempted}"
# true
# end

# export PARALLEL_PROCESSOR_COUNT=2 && rake tw:maintenance:collecting_events:tested_reindex_geographic_name_cached_values
desc 'check cached geographic names and re-indx where ncessary'
task tested_reindex_geographic_name_cached_values: [:environment] do |t|
updated = 0
Expand Down
Loading

0 comments on commit e1c859e

Please sign in to comment.