Class: Foxit::ETL
- Inherits:
-
Object
- Object
- Foxit::ETL
- Defined in:
- lib/foxit/etl.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#kitsu ⇒ Object
readonly
Returns the value of attribute kitsu.
Instance Method Summary collapse
- #get_anime(media_ids) ⇒ Object
- #get_libraries(user_ids) ⇒ Object
-
#initialize(db_name: 'kitsu', host: ['127.0.0.1:27017']) ⇒ ETL
constructor
A new instance of ETL.
- #insert_many_docs(collection_name, docs) ⇒ Object
Constructor Details
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/foxit/etl.rb', line 11 def client @client end |
#kitsu ⇒ Object (readonly)
Returns the value of attribute kitsu.
11 12 13 |
# File 'lib/foxit/etl.rb', line 11 def kitsu @kitsu end |
Instance Method Details
#get_anime(media_ids) ⇒ Object
36 37 38 39 |
# File 'lib/foxit/etl.rb', line 36 def get_anime media_ids docs = @kitsu.get_anime_documents(media_ids) insert_many_docs('anime', docs) end |
#get_libraries(user_ids) ⇒ Object
30 31 32 33 |
# File 'lib/foxit/etl.rb', line 30 def get_libraries user_ids docs = @kitsu.batch_get_libraries_docs(user_ids) insert_many_docs('library', docs) end |
#insert_many_docs(collection_name, docs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/foxit/etl.rb', line 18 def insert_many_docs collection_name, docs begin puts "inserting..." result = @client[collection_name].insert_many(docs) puts "records inserted: #{result.inserted_count}" rescue StandardError => e puts "error: #{e}" end puts "complete.\n" end |