Skip to content

Feature/preserve data#6

Open
yahyaelganyni1 wants to merge 33 commits into
devfrom
feature/preserve-data
Open

Feature/preserve data#6
yahyaelganyni1 wants to merge 33 commits into
devfrom
feature/preserve-data

Conversation

@yahyaelganyni1
Copy link
Copy Markdown
Collaborator

In this PR, I did the following:

  • Save data into JSON files on exit
  • Load all data from files.

Copy link
Copy Markdown

@mikethreels mikethreels left a comment

Choose a reason for hiding this comment

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

Hi Team,

Great job on saving the JSON files.
There are some issues that you still need to work on to go to the next project but you are almost there!

Required Changes ♻️

Check the comments under the review.

Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear.

Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

Comment thread persistor.rb
Comment on lines +29 to +32
if File.exist? file
JSON.parse(File.read(file)).map do |rental_json|
book = books.find { |current_book| current_book.title == rental_json['book_title'] }
person = people.find { |current_person| current_person.id == rental_json['person_id'].to_i }
Copy link
Copy Markdown

@mikethreels mikethreels Jan 13, 2022

Choose a reason for hiding this comment

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

  • on first start the application is firing and working as expected when closing the application the JSON files are created as well, however, when restarting the application is not firing and the user gets below error:
    Screenshot 2022-01-13 120202

the reason the user gets this error is because the information in the JSON files is saved as an array of strings and it can't find the title in the string. in order to make it work this way the data in your JSON file should be saved as an array of objects which will look something like in the below example:

[{"Title": "hp", "Author": "jk"},{"Title": "hp2", "Author": "jk"}]

In the example I'm using the books array but this also applies for the people and rental array.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

now i see the problem now but I fixed it someway else
thanks for the hint

Copy link
Copy Markdown

@Dipeshtwis Dipeshtwis left a comment

Choose a reason for hiding this comment

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

Status: Approved ✔️

Hi Team,

Good job on implementing the suggested changes. Well Done.
Your project is complete! There is nothing else to say other than... it's time to merge it :shipit:
Congratulations! 🎉

You may close this Pull Request and merge the changes

Keep being awesome devs and good luck with your next milestone!

Cheers and Happy coding!👏👏👏
Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Dipesh Kumar


As described in the Code reviews limits policy you have a limited number of reviews per project(check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

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.

5 participants