-
Notifications
You must be signed in to change notification settings - Fork 265
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
Speed up entry creation (#400) #491
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
class Mileage < Entry | ||
scope :by_last_created_at, -> { order("created_at DESC") } | ||
scope :by_last_updated_at, -> { order("updated_at DESC") } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
scope :by_date, -> { order("date DESC") } | ||
scope :billable, -> { where("billable").joins(:project) } | ||
scope :with_clients, -> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
= simple_form_for @hours_entry do |f| | ||
= f.error_notification | ||
= f.association :project, required: true, collection: Project.unarchived.by_name, label: false, placeholder: t("entries.index.project") | ||
= f.association :category, required: true, collection: Category.by_name, label: false, placeholder: t("entries.index.category") | ||
= f.input :value, required: true, label: false, placeholder: t("entries.index.hours") | ||
= f.association :project, required: true, collection: Project.unarchived.by_name, label: false, placeholder: t("entries.index.project"), selected: @last_hour_logged&.project_id || @hours_entry&.project_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using instance variables in partials views |
||
= f.association :category, required: true, collection: Category.by_name, label: false, placeholder: t("entries.index.category"), selected: @last_hour_logged&.category_id || @hours_entry&.category_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using instance variables in partials views |
||
= f.input :value, required: true, label: false, placeholder: t("entries.index.hours"), input_html: { value: @last_hour_logged&.value || @hours_entry&.value } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using instance variables in partials views |
||
= f.input :date, required: true, as: :string, input_html: { value: (@hours_entry.date || DateTime.current).strftime("%d/%m/%Y"), class: "datepicker"}, label: false | ||
.taggable | ||
= f.input :description, input_html: { data: { data: Tag.list }, autocomplete: :off }, label: false, autocomplete: "off", placeholder: t("entries.index.description") | ||
= f.input :description, input_html: { data: { data: Tag.list }, autocomplete: :off }, label: false, autocomplete: "off", placeholder: t("entries.index.description"), input_html: { value: @last_hour_logged&.description || @hours_entry&.description } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using instance variables in partials views |
||
%span.background-highlighter | ||
= f.button :submit, data: { disable_with: t("loader.saving") } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
= simple_form_for @mileages_entry do |f| | ||
= f.error_notification | ||
= f.association :project, required: true, collection: Project.unarchived.by_name, label: false, placeholder: t("entries.index.project") | ||
= f.input :value, required: true, as: :integer, label:false, placeholder: t("entries.index.mileages") | ||
= f.association :project, required: true, collection: Project.unarchived.by_name, label: false, placeholder: t("entries.index.project"), selected: @last_mileage_logged&.project_id || @mileages_entry&.project_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line contains trailing whitespace |
||
= f.input :value, required: true, as: :integer, label:false, placeholder: t("entries.index.mileages"), input_html: { value: @last_mileage_logged&.value || @mileages_entry&.value } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using instance variables in partials views |
||
= f.input :date, required: true, as: :string, input_html: { value: (@mileages_entry.date || DateTime.current).strftime("%d/%m/%Y"), class: "datepicker"}, label: false | ||
= f.button :submit, data: { disable_with: t("loader.saving") } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,16 @@ | |
end | ||
end | ||
|
||
describe "#by_last_updated_at" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
it "orders the entries by updated_at" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
initial_hour = create(:hour) | ||
Timecop.scale(600) | ||
create(:hour) | ||
initial_hour.update_attribute(:value, 2) | ||
expect(Hour.by_last_updated_at.first).to eq(initial_hour) | ||
end | ||
end | ||
|
||
describe "#by_date" do | ||
it "orders the entries by date (latest first)" do | ||
create(:hour, date: Date.new(2014, 01, 01)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,16 @@ | |
end | ||
end | ||
|
||
describe "#by_last_updated_at" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
it "orders the entries by updated_at" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
initial_hour = create(:mileage) | ||
Timecop.scale(600) | ||
create(:mileage) | ||
initial_hour.update_attribute(:value, 2) | ||
expect(Mileage.by_last_updated_at.first).to eq(initial_hour) | ||
end | ||
end | ||
|
||
describe "by_date" do | ||
it "orders the entries by date (latest first)" do | ||
create(:mileage, date: Date.new(2014, 01, 01)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.