Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo in "reccomend_textbook" #95

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def create
requires_attendance: review_params.attendance,
midterm_count: review_params.midterm_count,
final: review_params.final,
reccomend_textbook: review_params.textbook,
recommend_textbook: review_params.textbook,
comments: review_params.comments,
status: "pending",
)
Expand Down Expand Up @@ -183,7 +183,7 @@ def update
requires_attendance: review_params.attendance,
midterm_count: review_params.midterm_count,
final: review_params.final,
reccomend_textbook: review_params.textbook,
recommend_textbook: review_params.textbook,
comments: review_params.comments,
status: "pending",
)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/course_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def course_detail_icon(course_detail)
else
"icons/pencil-alt"
end
when :reccomend_textbook
when :recommend_textbook
"icons/book-open"
end
end
Expand Down Expand Up @@ -147,7 +147,7 @@ def course_detail_label(course_detail)
else
pluralize(value, "midterm")
end
when :reccomend_textbook
when :recommend_textbook
# Check if value is boolean
case value
when true
Expand Down
10 changes: 5 additions & 5 deletions app/models/review.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def self.course_details(reviews)
.pick(Arel.sql("mode() within group (order by requires_attendance)"))
midterm_count = reviews.where.not(midterm_count: nil)
.pick(Arel.sql("mode() within group (order by midterm_count)"))
textbook_reccomendations = reviews.where.not(reccomend_textbook: nil)
.group(:reccomend_textbook).count
textbook_reccomendations = reviews.where.not(recommend_textbook: nil)
.group(:recommend_textbook).count
textbook_reccomend_percentage = (textbook_reccomendations[true].to_f / textbook_reccomendations.values.sum)

details = []
Expand Down Expand Up @@ -106,7 +106,7 @@ def self.course_details(reviews)
end
unless textbook_reccomend_percentage.nan?
details.push({
label: :reccomend_textbook,
label: :recommend_textbook,
value: textbook_reccomend_percentage * 100,
})
end
Expand Down Expand Up @@ -216,8 +216,8 @@ def course_details
value: read_attribute_before_type_cast(:final),
},
{
label: :reccomend_textbook,
value: reccomend_textbook,
label: :recommend_textbook,
value: recommend_textbook,
},
]
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/reviews/_review.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ json.extra_credit(review.offers_extra_credit.to_s)
json.attendance(review.requires_attendance.to_s)
json.midterm_count(review.midterm_count.to_s)
json.final(review.read_attribute_before_type_cast(:final))
json.textbook(review.reccomend_textbook.to_s)
json.textbook(review.recommend_textbook.to_s)
json.comments(review.comments)
7 changes: 7 additions & 0 deletions db/migrate/20230611074937_rename_reccomend_textbook_column.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class RenameReccomendTextbookColumn < ActiveRecord::Migration[7.0]
def change
rename_column(:reviews, :reccomend_textbook, :recommend_textbook)
end
end
104 changes: 65 additions & 39 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -130,43 +130,6 @@ CREATE TYPE public.weekly_time_type AS ENUM (
);


--
-- Name: is_graduate(character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.is_graduate(num character varying) RETURNS boolean
LANGUAGE plpgsql IMMUTABLE STRICT
AS $$
BEGIN
RETURN (num SIMILAR TO '%[2-9][0-9][0-9]%');
END
$$;


--
-- Name: strposrev(text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.strposrev(instring text, insubstring text) RETURNS integer
LANGUAGE plpgsql IMMUTABLE STRICT COST 4
AS $$
DECLARE result INTEGER;
BEGIN
IF strpos(instring, insubstring) = 0 THEN
-- no match
result:=0;
ELSEIF length(insubstring)=1 THEN
-- add one to get the correct position from the left.
result:= 1 + length(instring) - strpos(reverse(instring), insubstring);
ELSE
-- add two minus the legth of the search string
result:= 2 + length(instring)- length(insubstring) - strpos(reverse(instring), reverse(insubstring));
END IF;
RETURN result;
END;
$$;


SET default_tablespace = '';

SET default_table_access_method = heap;
Expand Down Expand Up @@ -927,6 +890,39 @@ CREATE SEQUENCE public.pay_webhooks_id_seq
ALTER SEQUENCE public.pay_webhooks_id_seq OWNED BY public.pay_webhooks.id;


--
-- Name: pg_search_documents; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.pg_search_documents (
id bigint NOT NULL,
content text,
searchable_type character varying,
searchable_id bigint,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);


--
-- Name: pg_search_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.pg_search_documents_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


--
-- Name: pg_search_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.pg_search_documents_id_seq OWNED BY public.pg_search_documents.id;


--
-- Name: relationships; Type: TABLE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -974,9 +970,9 @@ CREATE TABLE public.reviews (
updated_at timestamp(6) without time zone NOT NULL,
has_group_project boolean,
requires_attendance boolean,
recommend_textbook boolean,
midterm_count integer,
final public.final_type,
reccomend_textbook boolean,
grade public.grade_type,
weekly_time public.weekly_time_type,
offers_extra_credit boolean,
Expand Down Expand Up @@ -1448,6 +1444,13 @@ ALTER TABLE ONLY public.pay_subscriptions ALTER COLUMN id SET DEFAULT nextval('p
ALTER TABLE ONLY public.pay_webhooks ALTER COLUMN id SET DEFAULT nextval('public.pay_webhooks_id_seq'::regclass);


--
-- Name: pg_search_documents id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.pg_search_documents ALTER COLUMN id SET DEFAULT nextval('public.pg_search_documents_id_seq'::regclass);


--
-- Name: relationships id; Type: DEFAULT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1679,6 +1682,14 @@ ALTER TABLE ONLY public.pay_webhooks
ADD CONSTRAINT pay_webhooks_pkey PRIMARY KEY (id);


--
-- Name: pg_search_documents pg_search_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.pg_search_documents
ADD CONSTRAINT pg_search_documents_pkey PRIMARY KEY (id);


--
-- Name: relationships relationships_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2025,6 +2036,20 @@ CREATE UNIQUE INDEX index_pay_payment_methods_on_customer_id_and_processor_id ON
CREATE UNIQUE INDEX index_pay_subscriptions_on_customer_id_and_processor_id ON public.pay_subscriptions USING btree (customer_id, processor_id);


--
-- Name: index_pg_search_documents_on_searchable; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX index_pg_search_documents_on_searchable ON public.pg_search_documents USING btree (searchable_type, searchable_id);


--
-- Name: index_pg_search_documents_on_to_tsvector_simple_content; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_pg_search_documents_on_to_tsvector_simple_content ON public.pg_search_documents USING gin (to_tsvector('simple'::regconfig, COALESCE(content, ''::text)));


--
-- Name: index_relationships_on_section_id; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2457,6 +2482,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230204030922'),
('20230228014101'),
('20230421233948'),
('20230430161016');
('20230430161016'),
('20230611074937');


6 changes: 3 additions & 3 deletions sorbet/rails-rbi/models/review.rbi

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

2 changes: 1 addition & 1 deletion test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@
midterm_count { 2 }
requires_attendance { false }
final { "finals" }
reccomend_textbook { false }
recommend_textbook { false }
end
end
8 changes: 4 additions & 4 deletions test/helpers/course_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,26 @@ class CourseHelperTest < ActionView::TestCase
end
end

describe "reccomend_textbook" do
describe "recommend_textbook" do
it "returns a string if the value is true" do
course_detail = {
label: :reccomend_textbook,
label: :recommend_textbook,
value: true,
}
assert_equal("Recommends textbook", course_detail_label(course_detail))
end

it "returns a string if the value is false" do
course_detail = {
label: :reccomend_textbook,
label: :recommend_textbook,
value: false,
}
assert_equal("Does not recommend textbook", course_detail_label(course_detail))
end

it "returns a percentage if given a number" do
course_detail = {
label: :reccomend_textbook,
label: :recommend_textbook,
value: 65,
}
assert_equal("65% recommend the textbook", course_detail_label(course_detail))
Expand Down
4 changes: 2 additions & 2 deletions test/models/review_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ReviewTest < ActiveSupport::TestCase
midterm_count: 2,
requires_attendance: false,
final: "10th",
reccomend_textbook: false)
recommend_textbook: false)
assert_equal(
[
{
Expand All @@ -118,7 +118,7 @@ class ReviewTest < ActiveSupport::TestCase
value: "10th",
},
{
label: :reccomend_textbook,
label: :recommend_textbook,
value: false,
},
],
Expand Down
6 changes: 3 additions & 3 deletions test/system/reviews_system_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ReviewsSystemTest < ApplicationSystemTestCase
assert_not review.requires_attendance
assert_equal 2, review.midterm_count
assert_predicate review, :finals_week?
assert review.reccomend_textbook
assert review.recommend_textbook
assert_not review.offers_extra_credit
assert_equal review_text, review.comments

Expand Down Expand Up @@ -166,7 +166,7 @@ class ReviewsSystemTest < ApplicationSystemTestCase
assert_not review.requires_attendance
assert_equal 2, review.midterm_count
assert_predicate review, :finals_week?
assert review.reccomend_textbook
assert review.recommend_textbook
assert_not review.offers_extra_credit
assert_equal review_text, review.comments
assert_equal "pending", review.status
Expand All @@ -193,7 +193,7 @@ class ReviewsSystemTest < ApplicationSystemTestCase
grade: "C+",
has_group_project: true,
requires_attendance: false,
reccomend_textbook: false,
recommend_textbook: false,
midterm_count: 2,
final: "finals",
offers_extra_credit: true), Review)
Expand Down
Loading