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

Create the import_chapter method #58

Merged
merged 17 commits into from
Oct 28, 2023
Merged

Conversation

dsomel21
Copy link
Collaborator

@dsomel21 dsomel21 commented Jun 3, 2023

Carl Johnson at Ganton gym

Description

This method is how we will import chapter translations into the database.

I added the documentation in the code, but I will write it here as well:

HOW IT WORKS:

  1. Add your CSV file to lib/imports/#{book.sequence}/#{chapter_number}.csv
  2. Pass in a chapter_number: Integer e.g. 3
  3. Call @book.import_chapter(3).

Assuming there is a 3.csv file in the correct directory, this will import the translations from the CSV into the 3rd chapter of @book (whichever book it is).

EXAMPLE:

Go into the rails console and do:

@book = Book.find_by(:sequence => 1)
@book.import_chapter(3)

This will search for a CSV file at lib/imports/1/3.csv (or raise error). The CSV file should have the following columns:

  • Chapter_Number: Integer
  • Chapter_Name: String
  • Chhand_Type: String
  • Tuk: String
  • Pauri_Number: Integer
  • Pauri_Translation_EN: String | NULL
  • Tuk_Translation_EN: String | NULL
  • Footnotes: String | NULL
  • Extended_Ref: String | NULL
  • Assigned_Singh: String | NULL
  • Extended_Meaning: String | NULL

New Changes

  • New method in Book model
  • New method in Chapter model
  • Installed a Gem called TTY Prompts. This drastically increase the quality of life when running into edge cases because it gives the user prompts.
  • Some Rubocop stuff
  • specs

Closes #57

How Has This Been Tested?

  • Added/Updated Specs
  • Manual Test

Screenshots or Videos

Screen Shot 2023-06-03 at 8 03 41 AM Screen Shot 2023-06-03 at 8 06 04 AM

@dsomel21
Copy link
Collaborator Author

dsomel21 commented Jun 3, 2023

I got some feedback on this pull request from some friends:

Screen Shot 2023-06-03 at 4 23 55 PM

and:

Screen Shot 2023-06-03 at 4 24 13 PM

@dsomel21 dsomel21 closed this in #59 Jun 4, 2023
@dsomel21 dsomel21 reopened this Jun 4, 2023
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'csv'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't think I needed this, but apparently I do 🤷🏾

@dsomel21 dsomel21 merged commit 660f639 into main Oct 28, 2023
1 check passed
return if chapter.title == chapter_name

message = "The name in Book #{book.sequence}, Chapter #{chapter_number} is " +
pastel.bold('presently') +

Choose a reason for hiding this comment

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

Nit: You could use string interpolation here instead of +

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.

Create Chapter Importer (CSV)
2 participants