profile
viewpoint
Benjamin Reynolds benreyn Kansas City, MO

benreyn/atreus-layout 1

just version control for my tinkering with my atreus layout on kbfirmware.com

benreyn/activerecord-precount 0

N+1 count query killer for ActiveRecord

benreyn/active_storage_validations 0

Do it like => validates :photos, attached: true, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: 500.kilobytes }, limit: { min: 1, max: 3 }, aspect_ratio: :landscape, dimension: { width: { in: 800..1600 }

benreyn/ahoy 0

Analytics for Rails

benreyn/ahoy_email 0

Simple, powerful email tracking for Rails

benreyn/alert 0

A Growl-like alerts notifier for Emacs

benreyn/alpha-blog 0

A slightly more advanced Rails Blog App

benreyn/Amethyst 0

Automatic tiling window manager for macOS à la xmonad.

push eventrubyforgood/abalone

Michelle Hey

commit sha 0f204eb09ce5e4025ac8070603e3b9bd904ddd19

Convert animals and cohort views to tailwindcss (#419) * add tailwind to animals * add tailwind to cohorts * fixed spacing * fixed broken specs

view details

push time in a day

delete branch rubyforgood/abalone

delete branch : convert-animals-and-cohorts-views-to-tailwindcss

delete time in a day

PR merged rubyforgood/abalone

Reviewers
Convert animals and cohort views to tailwindcss

PR to match animals and cohort styling to other models using tailwind

Screen Shot 2020-09-25 at 2 58 20 PM

Screen Shot 2020-09-25 at 2 58 11 PM

Screen Shot 2020-09-25 at 2 58 04 PM

+278 -246

0 comment

13 changed files

michellemhey

pr closed time in a day

issue commentrubyforgood/abalone

Install Blazer gem for Report and Dashboard generation.

@wadewinningham Would you mind putting together a Proof of concept for what this would look like, with instructions on how to setup DB users and permission? I know thats a big ask, but Im sure you know how much of a game changer that would be for this project.

benreyn

comment created time in 2 days

issue commentrubyforgood/abalone

Install Blazer gem for Report and Dashboard generation.

I think we had considered this before, Could we intercept an individual request and reset the user that Blazer uses for the db connection at runtime? I think the issue we ran into was that Blazers configuration is read from environment variables at the build step.

To clarify, setting up a new db user for each org we onboard is %💯 doable, as we are pretty sure theres going to be work involved for every org we onboard, so this amount of work is totally within bounds for the core team to undertake whenever an org is on-boarded. (As long as the process is well documented)

benreyn

comment created time in 2 days

issue closedrubyforgood/abalone

As an admin, I can add a new user to an organization

  • [ ] The UsersController new and create actions are added
  • [ ] A new view is added to this route that has a form for creating a new User record
  • [ ] This form can be submitted to add a new User record to the database
  • [ ] A feature test is added that loads this form and submits it, creating a new record.
  • [ ] Add specs that exercise the different outcomes for an admin and a user trying to perform this action.

There is some prior art for how we want new record form in our application to look and behave. See Facilities#new and Animals#new.

The existing pattern in our application for new forms is to redirect to the records show page with a success message after the new record is created.

This task is dependent on #339

closed time in 2 days

CraigJZ

Pull request review commentrubyforgood/abalone

[386] Set up Locations

-facility_code,name-AOP,Enclosure Number 1-AOP,Enclosure Number 2-AOP,Enclosure Number 2-QQQ,Enclosure Number 1-,\ No newline at end of file+facility_code,location_name,name+AOP,SeaLab2020,Enclosure Number 1+AOP,Atlantis,Enclosure Number 2+AOP,SeaWorld,Enclosure Number 2+QQQ,OceanPlace,Enclosure Number 1

🤣

bkrigel

comment created time in 2 days

Pull request review commentrubyforgood/abalone

[386] Set up Locations

+require 'rails_helper'++RSpec.describe Location, type: :model do+  pending "add some examples to (or delete) #{__FILE__}"+end

Are there any tests you think would be valuable to add here? if not, should we just delete this file until we do?

bkrigel

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

Reworked animal tags to be in a single string column

     visit new_animal_path      within('form') do-      fill_in 'animal_pii_tag', with: "An Animal"+      fill_in 'animal_tag', with: "An Animal"

So that our tests more closely match real world usage, thoughts on this change?

      fill_in 'animal_tag', with: "G127"
haydenrou

comment created time in 2 days

Pull request review commentrubyforgood/abalone

Reworked animal tags to be in a single string column

     within('tbody') { expect(page).to have_xpath('.//tr', count: 2) }      # Verify no duplicates and assigned to correct org-    animals = Animal.where(pii_tag: 2)+    animals = Animal.where(tag: "Y2")

If you take my suggestion about the factory above, you'll probably have a test to fix here.

haydenrou

comment created time in 2 days

Pull request review commentrubyforgood/abalone

Reworked animal tags to be in a single string column

-collection_year,date_time_collected,collection_position,pii_tag,tag_id,sex,unknown_column-2020,2020-09-22T08:16:24-04:00,sample,1,0,female,unknown_data-2020,2020-09-22T08:16:24-04:00,sample,2,0,female,unknown_data-2020,2020-09-22T08:16:24-04:00,sample,2,0,female,unknown_data\ No newline at end of file+collection_year,date_time_collected,collection_position,tag,sex,unknown_column
+2020,2020-09-22T08:16:24-04:00,sample,G1,female,unknown_data
+2020,2020-09-22T08:16:24-04:00,sample,Y2,female,unknown_data
+2020,2020-09-22T08:16:24-04:00,sample,Y2,female,unknown_data

Similar suggestion here about the code / data more closely resembling reality

2020,2020-09-22T08:16:24-04:00,sample,G001,female,unknown_data
2020,2020-09-22T08:16:24-04:00,sample,Y002,female,unknown_data
2020,2020-09-22T08:16:24-04:00,sample,Y2,female,unknown_data
haydenrou

comment created time in 2 days

Pull request review commentrubyforgood/abalone

Reworked animal tags to be in a single string column

     collection_year { 1 }     date_time_collected { "2020-04-04 18:52:09" }     collection_position { "MyString" }-    pii_tag { 1 }-    tag_id { 1 }+    sequence(:tag) { |n| "Y#{n}" }     sex { 'male' }     organization   end   factory :female, class: Animal do     collection_year { 1 }     date_time_collected { "2020-04-04 18:52:09" }     collection_position { "MyString" }-    pii_tag { 1 }-    tag_id { 1 }+    sequence(:tag) { |n| "R#{n}" }

Same suggestion here about left-padding the tag...

    sequence(:tag) { |n| "R#{sprintf('%03d', 1)}" }
haydenrou

comment created time in 2 days

Pull request review commentrubyforgood/abalone

Reworked animal tags to be in a single string column

     collection_year { 1 }     date_time_collected { "2020-04-04 18:52:09" }     collection_position { "MyString" }-    pii_tag { 1 }-    tag_id { 1 }+    sequence(:tag) { |n| "Y#{n}" }

So that factory data maps more closely to what we'll see in the real world, how would you feel about left-padding the n here?

    sequence(:tag) { |n| "Y#{sprintf('%03d', 1)}" }
haydenrou

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentrubyforgood/abalone

Tags: Rework how Animals are identified within an organization

I think...

  1. Drop tag_id, as we never really know what that was for
  2. Rename pii_tag to tag_number
  3. Add the new column for tag_color (or whatever other path seems right for this, if thats a tag_color table with a relationship, then I think thats fine too.

The important things to keep in mind here are...

  1. A tag, like G127 is not unique to animal, but unique to an animal within a cohort (cohorts now have_many animals as of #408
  2. When data gets imported into the application, the way that it usually will come in is in a CSV with a tag shorthand for an individual animal. Picture...
animal,length
G125,55
G126,43.2
G127,38

etc etc.

We want to make sure these operations can be done relatively performantly and without too much of a hack in the import code, but it IS probably worth separating the concept of a tag color and the number for that tag? This might be something we regret in the future, so happy to hear about an alternative if you have a good idea for one.

benreyn

comment created time in 3 days

PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

Allow user to change its own password

 Rails.application.routes.draw do   devise_for :users, path_prefix: 'app'   resources :users+  resources :passwords

Can we restrict this to..

  resources :passwords, only: [:edit, :update]

So we arent adding routes for controller actions that dont exist.

viniciusgama

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentrubyforgood/abalone

Add versioning with paper trail

Looks like sadly there were some pretty big conflicts with this PR and the tank and family renames. 😞

haydenrou

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Add CSV export to animals, facilities, enclosures, and cohorts

+module CsvExportable+  extend ActiveSupport::Concern++  class_methods do+    def exportable_columns+      column_names.reject { |col| %w[organization_id].include? col }+    end++    def to_csv+      CSV.generate(headers: true) do |csv|+        csv << exportable_columns+        all.each { |record| csv << exportable_columns.map { |attr| record.send(attr) } }+      end+    end+  end+end

Love this export module so its easy to add this to other models in the future. 👍

todtb

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

Allow user to change its own password

 class UsersController < ApplicationController   before_action :admin?, only: [:index, :show, :new, :create, :edit, :update, :destroy]-  before_action :set_user, only: [:show, :edit, :update, :destroy]+  before_action :set_user, only: [:show, :edit, :update, :destroy, :edit_password, :update_password]+  before_action :current_user?, only: [:edit_password, :update_password]

I tend to start to get worried when controllers state collection alot of before_action filters. It starts to make it difficult to folow the code path. "ok, what all method run before this controller action?", This gets even worse when we start having some before filters use except: and other use only:. If we pull this into its own controller we could clean this chunk of code up some.

viniciusgama

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Allow user to change its own password

 def destroy     redirect_to users_url, notice: notice_message   end +  def edit_password; end++  def update_password+    if @user.update(user_params)+      sign_in(@user, bypass: true)+      redirect_to edit_password_users_url, notice: 'Password was successfully updated.'+    else+      render :edit_password+    end+  end+   private    def user_params+    allowed_params = [:email, :password]+    allowed_params << :role if current_user.admin?     params.require(:user).permit(-      :email,-      :password,-      :role+      allowed_params

If we use a net new controller for this, we dont need to worry about the conditional modification of the params allowlist.

viniciusgama

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Allow user to change its own password

 def destroy     redirect_to users_url, notice: notice_message   end +  def edit_password; end++  def update_password+    if @user.update(user_params)+      sign_in(@user, bypass: true)+      redirect_to edit_password_users_url, notice: 'Password was successfully updated.'+    else+      render :edit_password+    end+  end+

I tend to prefer to keep my controllers and routes as RESTful as possible. i.e Only having controllers with the actions that are generated for free from resources or resource in the routes file. How would you feel about pulling this out into a PasswordsController#edit and PasswordsController#update action?

viniciusgama

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentrubyforgood/abalone

Add shl to animals

Is this Okay for a first pass, should we expand on it or create another task in the backlog to do this?

I think this is fine for a first pass, if we need to expand the csv import functionality to include SHL numbers in the future, then we can do so then. No need to add more functionality than we will know we need.

haydenrou

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Add shl to animals

     t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true   end +  create_table "versions", force: :cascade do |t|+    t.string "item_type", null: false+    t.bigint "item_id", null: false+    t.string "event", null: false+    t.string "whodunnit"+    t.text "object"+    t.datetime "created_at"+    t.text "object_changes"+    t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"+  end+

I think these are some schema changes we dont want in this diff.

haydenrou

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Add shl to animals

+require 'rails_helper'++RSpec.describe ShlNumber, type: :model do+  pending "add some examples to (or delete) #{__FILE__}"

✂️

haydenrou

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Add shl to animals

+require 'rails_helper'++RSpec.describe AnimalsShlNumber, type: :model do+  pending "add some examples to (or delete) #{__FILE__}"

✂️

haydenrou

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Add shl to animals

 def new   def create     @animal = Animal.new(animal_params) -    respond_to do |format|-      if @animal.save-        format.html { redirect_to @animal, notice: 'Animal was successfully created.' }-        format.json { render :show, status: :created, location: @animal }-      else-        format.html { render :new }-        format.json { render json: @animal.errors, status: :unprocessable_entity }

Thanks for going ahead and clearing out the unused json endpoints here 👍

haydenrou

comment created time in 3 days

Pull request review commentrubyforgood/abalone

Add shl to animals

 def new   def create     @animal = Animal.new(animal_params) -    respond_to do |format|-      if @animal.save-        format.html { redirect_to @animal, notice: 'Animal was successfully created.' }-        format.json { render :show, status: :created, location: @animal }-      else-        format.html { render :new }-        format.json { render json: @animal.errors, status: :unprocessable_entity }-      end+    params[:animal][:shl_numbers_codes].split(",").each do |code|+      @animal.shl_numbers.find_or_initialize_by(code: code)+    end

thoughts on extracting this param transformation logic into a private method on this controller?

haydenrou

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

issue openedrubyforgood/abalone

Add Cohort has_many Animals relationship

  • [ ] Add an animals.cohort_id
  • [ ] An animal belongs_to a cohort
  • [ ] A cohort has_many animals

This relationship is different is different from the Male and Female relationship on Cohort. These animals represent parentage.

created time in 3 days

PullRequestReviewEvent

issue commentrubyforgood/abalone

CSV upload for operations

Removing this from the MVP, as I think we can launch and provide value without it.

benreyn

comment created time in 3 days

push eventrubyforgood/abalone

Hayden Rouille

commit sha 441c1be078910b1739b479297d97d0b6964fff19

Rework measurements to have correct associations and values (#379) Rework measurements to have correct associations and values Add a measurement type model for tracking different measurements per organization for different values (e.g. length, count) and units (e.g. cm, integer) Move around associations to have a polymorphic assocations for the test subject, and measurements, measurement types and measurement events to belong to each other correctly. Remove tank_id from measurement event as they could belong to many different things which you can diverge from the associated measurements. Add specs for all of the above. Deprecate specs for CSVs and File Uploads, and assocaited methods on models, such as #create_from_csv . The reason for this is that they are going to be entirely reworked, and the current usage of them only facilities specs, and not provides functionality to the app. I'm expecting all these skipped tests will be removed further down the line when the CSV import is reworked. Co-authored-by: Brian Todt <todtb@users.noreply.github.com> Co-authored-by: Sebastian Kopp <smkopp92@gmail.com>

view details

push time in 4 days

PR merged rubyforgood/abalone

Rework measurements to have correct associations and values

Add a measurement type model for tracking different measurements per organization for different values (e.g. length, count) and units (e.g. cm, integer) Move around associations to have a polymorphic assocations for the test subject, and measurements, measurement types and measurement events to belong to each other correctly. Remove tank_id from measurement event as they could belong to many different things which you can diverge from the associated measurements. Add specs for all of the above. Deprecate specs for CSVs and File Uploads, and assocaited methods on models, such as #create_from_csv . The reason for this is that they are going to be entirely reworked, and the current usage of them only facilities specs, and not provides functionality to the app. I'm expecting all these skipped tests will be removed further down the line when the CSV import is reworked.

Co-authored-by: Brian Todt todtb@users.noreply.github.com Co-authored-by: Sebastian Kopp smkopp92@gmail.com

Checklist:

  • [ ] I have performed a self-review of my own code,
  • [ ] I have commented my code, particularly in hard-to-understand areas,
  • [ ] I have made corresponding changes to the documentation,
  • [ ] I have added tests that prove my fix is effective or that my feature works,
  • [ ] New and existing unit tests pass locally with my changes ("bundle exec rake"),
  • [ ] Title include "WIP" if work is in progress.

Resolves #308

Description

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. Guide questions:

  • What motivated this change (if not already described in an issue)?
  • What alternative solutions did you consider?
  • What are the tradeoffs for your solution?

List any dependencies that are required for this change. (gems, js libraries, etc.)

Include anything else we should know about. -->

Type of change

<!-- Please delete options that are not relevant. -->

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation update

How Has This Been Tested?

<!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Do we need to do anything else to verify your changes? If so, provide instructions (including any relevant configuration) so that we can reproduce? -->

Screenshots

<!--Optional. Delete if not relevant. Include screenshots (before / after) for style changes, highlight edited element.-->

+346 -57

0 comment

33 changed files

haydenrou

pr closed time in 4 days

issue closedrubyforgood/abalone

Measurement / MeasurementType Interface

An organization needs to define an acceptable list of measurement names and measurement value types for measurements that will be added to the system. This will most likely take the form of an interface exposed at the organization level.

Examples:

Measurement Name: Length
Measurement Value Type: Centimeters

Measurement Name: Age
Measurement Value Type: Days

Measurement Name: Weight
Measurement Value Type: Grams

Measurement Name: Quantity
Measurement Value Type: Units

The current structure of the Measurement model points to an approach where the acceptable measurement names and measurement value types are configured for the organization and then used to validate measurements as they are accepted into the system.

An alternative approach being considered is to add a MeasurementType model with the name, value type and an organization_id. A Measurement belongs_to a MeasurementType and a MeasurementType has_many measurements. A MeasurementType belongs_to an organization and an Organization has_many measurement types. The acceptable list would be the MeasurementType records for an organization and those would be used for Measurements being accepted into the system.

Tasks:

Note: These are broad and can be broken out into individual issues

  • [x] Determine an approach
  • [x] Add the MeasurementType model and relationships, if going with this approach
  • [x] Update the relevant seed files, factories and specs
  • [x] Build out the interface for defining these values at the organization level.

Note: The concept of an "organization level" means that an admin user for an organization would be defining these values. If this issue is addressed before #338, this concept can be ignored with the understanding that we would scope that level of access once #338 has been completed.

closed time in 4 days

benreyn
PullRequestReviewEvent

issue commentrubyforgood/abalone

CSV upload for measurement

After look at the sample data we got from our stakeholders, and having a few conversations with them, I think the following proposal is going to be the best way to implement the CSV upload that will represent a measurement event by a lab researcher into our system...

  1. Add a link to a page title "data import" or something else generic sounding
  2. On this page we let the user "build" an empty CSV. They can say..
  • I am taking measurements of animals
  • I want to measure length and gonad score
  1. This will generate a CSV with all the correct headers.
  2. The user can then download this CSV and fit the data from their lab notes into this CSV
  3. We then let the user upload this CSV, and it will create a measurement event with all of the appropriate measurements and relationships
benreyn

comment created time in 4 days

Pull request review commentrubyforgood/abalone

Add versioning with paper trail

 class Family < ApplicationRecord+  has_paper_trail+   include OrganizationScope -  belongs_to :male, class_name: 'Animal'-  belongs_to :female, class_name: 'Animal'+  belongs_to :male, class_name: 'Animal', optional: true

Yup. Good call. Under normal circumstances I probably would have done this in a separate PR, but fine to leave in here.

haydenrou

comment created time in 4 days

PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

Add versioning with paper trail

 class Family < ApplicationRecord+  has_paper_trail

This is great, I think I intended to have it here as well but just missed making the issue.

haydenrou

comment created time in 4 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

Rework measurements to have correct associations and values

+class MeasurementType < ApplicationRecord+  include OrganizationScope

I dont know when this got added, but I ❤️ this abstraction.

haydenrou

comment created time in 4 days

Pull request review commentrubyforgood/abalone

Rework measurements to have correct associations and values

 # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_09_23_153522) do+ActiveRecord::Schema.define(version: 2020_09_23_154527) do    # These are extensions that must be enabled in order to support this database   enable_extension "plpgsql"    create_enum :animal_sex, [-      "unknown",-      "male",-      "female",+    "unknown",+    "male",+    "female",

Weird that this ended up in the diff. Maybe it has to do with the version of Postgres your running locally? Ive seen that be the cause of weird diffs in schema.rb in other projects in the past.

haydenrou

comment created time in 4 days

Pull request review commentrubyforgood/abalone

Rework measurements to have correct associations and values

 family = Family.create!(male: male, female: female, organization_id: white_abalone.id) tank = Tank.create!(facility: Facility.find_by(code: 'PSRF'), name: 'AB-17', organization_id: white_abalone.id) Operation.create!(tank: tank, animals_added: 800, family: family, operation_date: 7.days.ago, action: :add_family, organization_id: white_abalone.id)-measurement_event = MeasurementEvent.create!(name: "My first measurement", tank: tank, organization_id: white_abalone.id)-Measurement.create!(name: 'count', value_type: 'integer', value: '743', measurement_event: measurement_event, date: 3.days.ago, organization_id: white_abalone.id)-Measurement.create!(name: 'count', value_type: 'integer', value: '719', measurement_event: measurement_event, date: 1.days.ago, organization_id: white_abalone.id)+measurement_event = MeasurementEvent.create!(name: "My first measurement", organization_id: white_abalone.id)+measurement_type = MeasurementType.create!(name: "length", unit: "cm", organization: white_abalone)+measurement_type = MeasurementType.create!(name: "count", unit: "number", organization: white_abalone)+measurement_type = MeasurementType.create!(name: "weight", unit: "g", organization: white_abalone)+measurement_type = MeasurementType.create!(name: "gonad score", unit: "number", organization: white_abalone)+Measurement.create!(value: '743', measurement_event: measurement_event, date: 3.days.ago, organization_id: white_abalone.id, subject: male, measurement_type: measurement_type)+Measurement.create!(value: '719', measurement_event: measurement_event, date: 1.days.ago, organization_id: white_abalone.id, subject: female, measurement_type: measurement_type)

I think this is fine, but we will probably need to revisit these seeds at some point in the future to make sure that it sets up the application in a state that accurately portrays its daily usage.

haydenrou

comment created time in 4 days

Pull request review commentrubyforgood/abalone

Rework measurements to have correct associations and values

 class Tank < ApplicationRecord    belongs_to :facility, optional: true   has_many :operations, dependent: :destroy-  has_many :measurement_events, dependent: :destroy-  # has_many :measurements, through: :measurement_events-  has_many :measurements+  has_many :post_settlement_inventories

Safe to remove.

haydenrou

comment created time in 4 days

Pull request review commentrubyforgood/abalone

Rework measurements to have correct associations and values

    create_table "measurement_events", force: :cascade do |t|     t.string "name"-    t.bigint "tank_id"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.bigint "organization_id"     t.index ["organization_id"], name: "index_measurement_events_on_organization_id"-    t.index ["tank_id"], name: "index_measurement_events_on_tank_id"   end -  create_table "measurements", force: :cascade do |t|+  create_table "measurement_types", force: :cascade do |t|     t.string "name"-    t.string "value_type"-    t.jsonb "value"+    t.string "unit"+    t.bigint "organization_id"+    t.datetime "created_at", precision: 6, null: false+    t.datetime "updated_at", precision: 6, null: false+    t.index ["organization_id"], name: "index_measurement_types_on_organization_id"+  end++  create_table "measurements", force: :cascade do |t|+    t.string "value", null: false     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.datetime "date"     t.bigint "measurement_event_id"     t.bigint "processed_file_id"-    t.bigint "animal_id"-    t.bigint "family_id"-    t.bigint "tank_id"     t.bigint "organization_id"-    t.index ["animal_id"], name: "index_measurements_on_animal_id"-    t.index ["family_id"], name: "index_measurements_on_family_id"+    t.string "subject_type", null: false+    t.bigint "subject_id", null: false+    t.bigint "measurement_type_id"     t.index ["measurement_event_id"], name: "index_measurements_on_measurement_event_id"+    t.index ["measurement_type_id"], name: "index_measurements_on_measurement_type_id"     t.index ["organization_id"], name: "index_measurements_on_organization_id"     t.index ["processed_file_id"], name: "index_measurements_on_processed_file_id"-    t.index ["tank_id"], name: "index_measurements_on_tank_id"+    t.index ["subject_type", "subject_id"], name: "index_measurements_on_subject_type_and_subject_id"

Good call adding this index 👍

haydenrou

comment created time in 4 days

PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

Rework measurements to have correct associations and values

 FactoryBot.define do   factory :measurement do-    name { "MyString" }-    value_type { "MyString" }     value { "" }+    measurement_type+    association :subject, factory: :tank

I think :animal will likely end up being the default we want here, and we will likely add traits for the rest of the possibilities in the polymorphic association.

haydenrou

comment created time in 4 days

Pull request review commentrubyforgood/abalone

Rework measurements to have correct associations and values

   it "Tank has associations" do     is_expected.to belong_to(:facility).optional     is_expected.to belong_to(:organization)+    is_expected.to have_many(:post_settlement_inventories)

This can safely be removed. PostSettlementInventory is one of the old models that was removed in #375

haydenrou

comment created time in 4 days

PullRequestReviewEvent
PullRequestReviewEvent

issue openedrubyforgood/abalone

Rename Family model to Cohort

We've found that the concept of a Family is maybe a bit too specific for our application, and we want to rename it to Cohort

created time in 4 days

issue openedrubyforgood/abalone

Rename Tank model to Enclosure

We've found that the concept of a Tank is maybe a bit too specific for our application, and we want to rename it to Enclosure

created time in 4 days

push eventrubyforgood/abalone

Vinicius Gama

commit sha c55921398d2cf4588749680ea07a3093796e3fbc

Removes consolidation report from code (#374)

view details

push time in 4 days

PR merged rubyforgood/abalone

Reviewers
[324] Removes consolidation report from code

Checklist:

  • [x] I have performed a self-review of my own code,
  • [x] I have commented my code, particularly in hard-to-understand areas,
  • [x] I have made corresponding changes to the documentation,
  • [x] I have added tests that prove my fix is effective or that my feature works,
  • [x] New and existing unit tests pass locally with my changes ("bundle exec rake"),
  • [x] Title include "WIP" if work is in progress.

Resolves #324

Description

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. Guide questions:

  • What motivated this change (if not already described in an issue)?
  • What alternative solutions did you consider?
  • What are the tradeoffs for your solution?

List any dependencies that are required for this change. (gems, js libraries, etc.)

Include anything else we should know about. -->

Type of change

  • Technical Debt

How Has This Been Tested?

<!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Do we need to do anything else to verify your changes? If so, provide instructions (including any relevant configuration) so that we can reproduce? -->

Screenshots

<!--Optional. Delete if not relevant. Include screenshots (before / after) for style changes, highlight edited element.-->

+8 -36

0 comment

5 changed files

viniciusgama

pr closed time in 4 days

issue closedrubyforgood/abalone

Remove all unused code related to ConsolidationReport model

The ConsolidationReport model is no longer in use. It was built for an earlier version of the applications architecture and can safely be deleted. Please ensure that all related code (including any spec files) is also deleted.

closed time in 4 days

benreyn
PullRequestReviewEvent

push eventrubyforgood/abalone

Ayako Kurushima

commit sha d1d854af3676808172cedd28004c24957a9e909e

Remove population estimate model and related code

view details

push time in 4 days

PR merged rubyforgood/abalone

Reviewers
Remove population estimate model and related code

Resolves #327

Description

Removes the population estimate model and related code since it is no longer used.

Type of change

  • Refactoring

How Has This Been Tested?

Ran entire test suite

+13 -303

0 comment

14 changed files

miniyakkos

pr closed time in 4 days

issue closedrubyforgood/abalone

Remove all unused code related to PopulationEstimate model

The PopulationEstimate model is no longer in use. It was built for an earlier version of the applications architecture and can safely be deleted. Please ensure that all related code (including any spec files) is also deleted.

closed time in 4 days

benreyn
PullRequestReviewEvent

PR merged rubyforgood/abalone

Reviewers
Include facilities for tanks to avoid n+1 query

This PR aims to fix an n+1 query on the tanks page.

Checklist:

  • [x] I have performed a self-review of my own code,
  • [x] I have commented my code, particularly in hard-to-understand areas,
  • [x] I have made corresponding changes to the documentation,
  • [x] I have added tests that prove my fix is effective or that my feature works,
  • [x] New and existing unit tests pass locally with my changes ("bundle exec rake"),
  • [x] Title include "WIP" if work is in progress.

-->

Resolves #365

Description

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. Guide questions:

  • What motivated this change (if not already described in an issue)?
  • What alternative solutions did you consider?
  • What are the tradeoffs for your solution?

List any dependencies that are required for this change. (gems, js libraries, etc.)

Include anything else we should know about. -->

Type of change

<!-- Please delete options that are not relevant. -->

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation update

How Has This Been Tested?

<!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Do we need to do anything else to verify your changes? If so, provide instructions (including any relevant configuration) so that we can reproduce? -->

Screenshots

<!--Optional. Delete if not relevant. Include screenshots (before / after) for style changes, highlight edited element.-->

+1 -1

0 comment

1 changed file

haydenrou

pr closed time in 4 days

issue closedrubyforgood/abalone

N+1 query

There’s a N+1 issue with facilities when loading the tanks page. Worth a PR to stamp that out. We should be checking for that on any pages we’re contributing. (wade)

closed time in 4 days

haydenrou
PullRequestReviewEvent

pull request commentrubyforgood/abalone

Add organizations to remaining models

Thanks for taking this on @haydenrou!

haydenrou

comment created time in 4 days

push eventrubyforgood/abalone

Hayden Rouille

commit sha 8f1edfe4c29263ffd85d0e8b00d69e4ab9211367

Add organizations to operations, measurements and measurement events (#367)

view details

push time in 4 days

PR merged rubyforgood/abalone

Reviewers
Add organizations to remaining models

This PR addresses #363

Checklist:

  • [x] I have performed a self-review of my own code,
  • [x] I have commented my code, particularly in hard-to-understand areas,
  • [x] I have made corresponding changes to the documentation,
  • [x] I have added tests that prove my fix is effective or that my feature works,
  • [x] New and existing unit tests pass locally with my changes ("bundle exec rake"),
  • [x] Title include "WIP" if work is in progress.

-->

Resolves #363

Description

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. Guide questions:

  • What motivated this change (if not already described in an issue)?
  • What alternative solutions did you consider?
  • What are the tradeoffs for your solution?

List any dependencies that are required for this change. (gems, js libraries, etc.)

Include anything else we should know about. -->

Type of change

<!-- Please delete options that are not relevant. -->

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation update

How Has This Been Tested?

<!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Do we need to do anything else to verify your changes? If so, provide instructions (including any relevant configuration) so that we can reproduce? -->

Screenshots

<!--Optional. Delete if not relevant. Include screenshots (before / after) for style changes, highlight edited element.-->

+58 -12

1 comment

20 changed files

haydenrou

pr closed time in 4 days

issue closedrubyforgood/abalone

Scope remaining relevant models to an Organization

Fallout from https://github.com/rubyforgood/abalone/pull/351

For the following : Operation, Measurement and MeasurementEvent

  • [x] Add a belongs_to relationship on The Model

  • [x] Add a has_many relationship on Organization

  • [x] Add an organization_id column to The Model with an index

  • [x] Update existing factory for The Model with an organization

  • [x] Add specs to Organization and to The Model for the added relationship

  • [x] Check relevant controllers and views to ensure we are not using .all, but scoping to organization.

closed time in 4 days

haydenrou

push eventrubyforgood/abalone

Igor Valente Blackman

commit sha 51bd953013b3fe8b13ff6d68a3fab51f0cb54482

Use alpine and fix yarn install Signed-off-by: Igor Valente Blackman <igor.blackman@gmail.com>

view details

Igor Valente Blackman

commit sha 4c11e5c39a72d59d4f0411a9620ba4b17cc55d98

run as non privileged user Signed-off-by: Igor Valente Blackman <igor.blackman@gmail.com>

view details

push time in 4 days

PR merged rubyforgood/abalone

Reviewers
Use alpine and fix yarn install

<!--Read comments, before commiting pull request read checklist again

Checklist:

  • [ ] I have performed a self-review of my own code,
  • [ ] I have commented my code, particularly in hard-to-understand areas,
  • [ ] I have made corresponding changes to the documentation,
  • [ ] I have added tests that prove my fix is effective or that my feature works,
  • [ ] New and existing unit tests pass locally with my changes ("bundle exec rake"),
  • [ ] Title include "WIP" if work is in progress.

Resolves <fill issue number> -->

Description

Please also include relevant motivation and context. Guide questions:

  • What motivated this change (if not already described in an issue)? We were not able to start up the docker environment using docker-compose. It was throwing an error about webpacker. Since the dockerfile was already needing some attention we decided to change it a bit.
  • What alternative solutions did you consider? Trying to fix with the old dockerfile didn't look too promising.
  • What are the tradeoffs for your solution? It works now.

List any dependencies that are required for this change. (gems, js libraries, etc.)

  • No changes.

Type of change

<!-- Please delete options that are not relevant. -->

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Just follow up the README instruction for the docker environment.

+55 -14

0 comment

2 changed files

iblackman

pr closed time in 4 days

PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

[354] Make animals.sex an enum

        <p>         <strong>Sex:</strong>-        <%= @animal.sex %>+        <%= @animal.sex&.humanize %>

Actually yes! In our meeting with stakeholders yesterday, and in the data files they have sent us, there are many cases where the sex of an animal is unknown or not able to be determined until the animal is more mature.

My preference would be to make the column non-nullable in the database and add a third "unknown" option to the enum.

viniciusgama

comment created time in 4 days

PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

[338] Feature - Added role column to users table

 class User < ApplicationRecord+  enum role: %i[user admin]+  after_initialize :set_default_role, if: :new_record?++  def set_default_role+    self.role ||= :user

I prefer encapsulating creation logic in a service object over using ActiveRecord callbacks, as the callback route has bitten me in the past, but its fine to go this route for now as its only one thing we piece of logic we need to add at the time of record creation.

michellemhey

comment created time in 5 days

PullRequestReviewEvent
PullRequestReviewEvent

issue closedrubyforgood/abalone

As a user, I can view a Family record

Acceptance Criteria

  • [ ] A new route is added that maps to Family#show
  • [ ] A new view is added to this route that shows all of the data for a family
  • [ ] A feature test is added that seeds one family record in the database, loads this page and asserts that content is on the page for that family

There is some prior art for how we want show pages in our application to look. See Facilities#new and Animals#new. If this task is picked up before #312, Please add to the scope of that issue, or create a new issue for.

  • [ ] A link to this page is added to the Families#index page.

If this task is picked up after #314, Please create a new ticket to correct the behavior of that form. It should redirect to this page after a new record is created.

closed time in 6 days

benreyn

issue closedrubyforgood/abalone

As a user, I can delete a Family record

Acceptance Criteria

  • [ ] A route is added that maps to Families#destroy
  • [ ] A button/link is added to the Families#index page created in #312
  • [ ] This action should ask for confirmation before this destructive action is taken
  • [ ] A feature test is added that seeds a family record in the database, loads the Families#index page and clicks to delete the record, then asserts the record is no longer on the page

closed time in 6 days

benreyn

issue closedrubyforgood/abalone

As a user, I can create a new Family

Acceptance Criteria

  • [ ] A new route is added that maps to Families#new
  • [ ] A new view is added to this route that has a form for creating a new Family record
  • [ ] This form can be submitted to add a new Family record to the database
  • [ ] A feature test is added that loads this form and submits it, creating a new record.

There is some prior art for how we want new record form in our application to look and behave. See Facilities#new and Animals#new. If this task is picked up before #312, Please add to the scope of that issue, or create a new issue for...

  • [ ] A link to this form is added to the Families#index page.

The existing pattern in our application for new forms is to redirect to the records show page with a success message after the new record is created. If #316 is not completed yet when this task is picked up, you may redirect to the index page, or re-render the new form with a success message, and follow up with the correct behavior once #316 is completed

closed time in 6 days

benreyn

issue closedrubyforgood/abalone

As a user, I can update a Family record

Acceptance Criteria

  • [ ] A new route is added that maps to Families#edit
  • [ ] A new view is added that renders a form, pre-populated with the data for the existing Family record, for the user to edit. Idealy this could re-use the markup for the form created in #314
  • [ ] This form can be submitted to update the family record in the database.
  • [ ] A feature test is added that seeds the database with a family record, loads this page, makes an edit to that record, and submits the form

closed time in 6 days

benreyn

issue openedrubyforgood/abalone

Make animals.sex and enum

The sex column on the animals table is currently stored as a raw string with no validation. To help ensure our data-integrity long term we should migrate this to an enum column. My preference would be to use a native Postgres enum type, as we will almost certainly want to query this data in SQL one day, and mapping rails enums to integers in the database leads to more back and forth than I tend to like.

Worth noting here is that based on what I've been able to tell from the sample data files we've gotten from our stakeholders, it appears that they are not always able to determine the sex of a given animal (my assumption here is that this is due to maturity?). This can either be represented by a null value in the sex column, or (preferably IMO) a third unknown option for this enum type.

created time in 6 days

issue openedrubyforgood/abalone

Remove unused JSON endpoints.

As much of the application in its current state was built with Rails scaffolds, we have a good number of controllers that can respond with JSON that do not need to. Lets clear out these unused code paths so there isnt any confusion down the road.

created time in 6 days

Pull request review commentrubyforgood/abalone

WIP: Add CRUD pages for family resource

+<section class="section facilities__index">+  <div class="container facilities__index__container">+    <p id="notice"><%= notice %></p>++    <div class="facilities__index__container__header">+      <h1 class="title">Families</h1>+      <%= link_to new_family_path, class: "button-primary" do %>+        New Family <%= image_tag  "icons/plus.png", size: 17 %>+      <% end %>+    </div>++    <table class="table  table-hover table-responsive-sm">+      <thead>+      <tr class="bg-dark-light">+        <th>Name</th>+        <th>Female</th>+        <th>Male</th>+        <th>Tank</th>+        <th colspan="3"></th>+      </tr>+      </thead>++      <tbody>+      <% @families.each do |family| %>+        <tr>+          <td><%= family.name %></td>+          <td><%= link_to family.female.pii_tag, animal_path(family.female) %></td>+          <td><%= link_to family.male.pii_tag, animal_path(family.male) %></td>

Im working on teasing that out from the data we have from our stakeholders, and digging through legacy code from when I joined the project. Ill follow up on this ASAP.

todtb

comment created time in 6 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentrubyforgood/abalone

[315] Create New Tank

 class Facility < ApplicationRecord   belongs_to :organization   after_commit { Rails.cache.delete('facility_codes') } +  scope :for_organization, ->(organization_id) { where organization_id: organization_id }

Im wondering if it would improve the developer experience for using this scope if we had it accept an organization rather than an organization_id. I believe...

  scope :for_organization, ->(organization) { where organization: organization }

Should work? That said, I dont know if its actually any better, and we may end up in situations where we have an id but not an actual ActiveRecord object, and we might prefer this setup. Thoughts?

Also, should we unit test this scope?

darrendc

comment created time in 6 days

PullRequestReviewEvent
more