Skip to content

Commit

Permalink
Merge pull request #6 from MITLibraries/ENGX-233-searchevent-and-term
Browse files Browse the repository at this point in the history
Adds Searchevent and term
  • Loading branch information
JPrevost authored Oct 23, 2023
2 parents 22d50bd + f3eae91 commit ae113b7
Show file tree
Hide file tree
Showing 18 changed files with 334 additions and 34 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "bundler" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
10 changes: 10 additions & 0 deletions .github/workflows/mit-libraries-ruby-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
shared:
uses: mitlibraries/.github/.github/workflows/ruby-shared-ci.yml@main
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@

# Ignore master key for decrypting credentials and more.
/config/master.key

# Ignore simplecov generated files
/coverage
68 changes: 39 additions & 29 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
source "https://rubygems.org"
source 'https://rubygems.org'
ruby '3.2.2'

ruby "3.2.2"
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.1"
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem 'importmap-rails'

# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem 'jbuilder'

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"
gem 'puma', '>= 5.0'

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'rails', '~> 7.1.1'

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem 'sprockets-rails'

# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
gem 'turbo-rails'

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
gem 'stimulus-rails'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[windows jruby]

# Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1"
Expand All @@ -35,34 +45,34 @@ gem "jbuilder"
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ]
gem 'debug', platforms: %i[mri windows]
end

group :development do
# Add annotations to model, test, fixtures when run
gem 'annotate'

# RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter.
gem 'rubocop'
gem 'rubocop-capybara'
gem 'rubocop-rails'

# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
gem 'web-console'

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"

# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"

end

group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem 'capybara'
gem 'selenium-webdriver'
gem 'simplecov'
gem 'simplecov-lcov'
end
47 changes: 47 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
ast (2.4.2)
base64 (0.1.1)
bigdecimal (3.1.4)
bindex (0.8.1)
Expand All @@ -98,6 +102,7 @@ GEM
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
docile (1.4.0)
drb (2.1.1)
ruby2_keywords
erubi (1.12.0)
Expand All @@ -115,6 +120,8 @@ GEM
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -145,6 +152,10 @@ GEM
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
psych (5.1.1)
stringio
public_suffix (5.0.3)
Expand Down Expand Up @@ -188,19 +199,48 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.0.6)
rdoc (6.5.0)
psych (>= 4.0.0)
regexp_parser (2.8.2)
reline (0.3.9)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.57.1)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-rails (2.21.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-webdriver (4.14.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand All @@ -222,6 +262,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -242,14 +283,20 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
annotate
bootsnap
capybara
debug
importmap-rails
jbuilder
puma (>= 5.0)
rails (~> 7.1.1)
rubocop
rubocop-capybara
rubocop-rails
selenium-webdriver
simplecov
simplecov-lcov
sprockets-rails
sqlite3 (~> 1.4)
stimulus-rails
Expand Down
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
17 changes: 17 additions & 0 deletions app/models/search_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: search_events
#
# id :integer not null, primary key
# term_id :integer
# source :string
# created_at :datetime not null
# updated_at :datetime not null
#
class SearchEvent < ApplicationRecord
belongs_to :term

validates :source, presence: true
end
14 changes: 14 additions & 0 deletions app/models/term.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: terms
#
# id :integer not null, primary key
# phrase :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Term < ApplicationRecord
has_many :search_events, dependent: :destroy
end
9 changes: 9 additions & 0 deletions db/migrate/20231019183700_create_terms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateTerms < ActiveRecord::Migration[7.1]
def change
create_table :terms do |t|
t.string :phrase, index: { unique: true, name: 'unique_phrase' }
t.timestamps
end

end
end
11 changes: 11 additions & 0 deletions db/migrate/20231019191933_create_search_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateSearchEvents < ActiveRecord::Migration[7.1]
def change
create_table :search_events do |t|
t.belongs_to :term
t.string :source
t.timestamps
end

add_index :search_events, :source
end
end
30 changes: 30 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "test_helper"
# frozen_string_literal: true

require 'test_helper'

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
Expand Down
4 changes: 3 additions & 1 deletion test/channels/application_cable/connection_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "test_helper"
# frozen_string_literal: true

require 'test_helper'

module ApplicationCable
class ConnectionTest < ActionCable::Connection::TestCase
Expand Down
17 changes: 17 additions & 0 deletions test/fixtures/search_events.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# == Schema Information
#
# Table name: search_events
#
# id :integer not null, primary key
# term_id :integer
# source :string
# created_at :datetime not null
# updated_at :datetime not null
#

timdex_cool:
term: cool
source: timdex
bento_hi:
term: hi
source: bento
15 changes: 15 additions & 0 deletions test/fixtures/terms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# == Schema Information
#
# Table name: terms
#
# id :integer not null, primary key
# phrase :string
# created_at :datetime not null
# updated_at :datetime not null
#

cool:
phrase: Super cool search

hi:
phrase: hello world
Loading

0 comments on commit ae113b7

Please sign in to comment.