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

Speed up entry creation (#400) #491

Conversation

jattoabdul
Copy link

What does this PR do?

  • Fetches the last hour and mileage logged by a user
  • Persist the last hour and mileage on the hours and mileages creation form respectively
  • Write Tests for modifications, adding model tests for scopes added

Description of Task to be completed?

How should this be manually tested?

  • Running the application tests, making sure none fails including the newly added model tests.
  • Ensuring that the hours and kilometers creation forms are prefilled with last created or updated hour or kilometer respectively.
  • Also, ensure that on an attempt to edit an hour or kilometer entry, the selected entry is properly updated

Any background context you want to provide?

  • None

What are the relevant issues?

Screenshots (if appropriate)

Screen Shot 2019-04-18 at 12 32 56 AM

Screen Shot 2019-04-18 at 12 32 58 AM

Questions:

  • N/A

…of new record and add model test for scope added
@@ -46,6 +46,16 @@
end
end

describe "#by_last_updated_at" do
it "orders the entries by updated_at" do

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.

@@ -46,6 +46,16 @@
end
end

describe "#by_last_updated_at" do

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.

@@ -90,6 +90,16 @@
end
end

describe "#by_last_updated_at" do
it "orders the entries by updated_at" do

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.

@@ -90,6 +90,16 @@
end
end

describe "#by_last_updated_at" do

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.

= 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
= f.input :value, required: true, as: :integer, label:false, placeholder: t("entries.index.mileages"), input_html: { value: @last_mileage_logged&.value || @mileages_entry&.value }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using instance variables in partials views
Line is too long. [181/80]

= 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
= 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
= f.input :value, required: true, label: false, placeholder: t("entries.index.hours"), input_html: { value: @last_hour_logged&.value || @hours_entry&.value }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using instance variables in partials views
Line is too long. [159/80]

= 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
= 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using instance variables in partials views
Line is too long. [200/80]

= 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using instance variables in partials views
Line is too long. [206/80]

@@ -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") }

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.

@@ -27,6 +27,7 @@ class Hour < Entry
accepts_nested_attributes_for :taggings

scope :by_last_created_at, -> { order("created_at DESC") }
scope :by_last_updated_at, -> { order("updated_at DESC") }

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.

Copy link
Contributor

@fatboypunk fatboypunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@jurre
Copy link
Contributor

jurre commented Jan 30, 2020

We've decided to freeze feature development as none of the maintainers currently have time to properly steward contributions from the community.

@jurre jurre closed this Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants