hearthside-marginalia 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d3649cd1ba78b13ce9933a9cf69fc4d2217b3be13c0e6b69b990acd6e3e55a2
4
- data.tar.gz: 5be51a1c11be6da3221a4af535f225bdb0e3e91448c599b950470ef5894269ad
3
+ metadata.gz: 14c7ff324f7b80a8c952fb664f59bbdd40df805150fef4a7bb99295fbd46a9c4
4
+ data.tar.gz: d2591c9ec246923e0a4395015ba132acc65d6b73bba85e74d60c98e34c3bad51
5
5
  SHA512:
6
- metadata.gz: 5a65a0aea0a77bd6baf05c98200aff53e80da965ee511361b779f6d8db2692a9afa42130268365cd1a625327e8deb3ce8817a2c1f1891e21926b6834aedfd8bb
7
- data.tar.gz: 84c546a05844033ecbad41ca73499a6d995f4381a001720e047233ea3510ed52540911d9af0c30c5518905b6f2efa7d813113ae3155a7ea1679f69a6b0495ca1
6
+ metadata.gz: bafefb3a1996354fbc23e51927dd99927dcd70714471711f48bf65239cf9f2f3bedcb0e40f05e25c448f9cc8991450a567d03c23471cd4412f2e2368c7a44955
7
+ data.tar.gz: 50d7bb0dbc6b374768149c35cb6b2b0e11019ccfc3fb20dc987fdc33419b905b2ef45b19a074136841cc1a3b6a8cadb8fbb82385580cba39dcfca0f66ecfb8b6
@@ -2,7 +2,7 @@ class Marginalia::Book < Marginalia::ApplicationRecord
2
2
  # has_many :author_contributions, class_name: Marginalia::Contribution.name
3
3
  # has_many :authors, class_name: Marginalia::Person.name, through: :author_contributions
4
4
  # has_many :highlights
5
- has_many :updates
5
+ has_many :updates, -> { order(created_at: :asc, progress: :asc) }
6
6
  # has_many :genres
7
7
 
8
8
  validates :title, presence: true
@@ -12,11 +12,19 @@ class Marginalia::Book < Marginalia::ApplicationRecord
12
12
  enum format: [:hardcover, :paperback, :ebook, :audio].to_h { [_1, _1.to_s] }
13
13
 
14
14
  def progress
15
- case format.to_sym
15
+ case format&.to_sym
16
16
  when :audio
17
- updates.order(:created_at).last.progress.to_f / minutes.to_f
17
+ if minutes.to_f == 0.0
18
+ 100
19
+ else
20
+ updates.last.progress.to_f / minutes.to_f
21
+ end
18
22
  else
19
- updates.order(:created_at).last.progress.to_f / pages.to_f
23
+ if pages.to_f == 0.0
24
+ 100
25
+ else
26
+ updates.last.progress.to_f / pages.to_f
27
+ end
20
28
  end
21
29
  end
22
30
  end
@@ -3,14 +3,16 @@ class CreateMarginaliaBooks < ActiveRecord::Migration[7.0]
3
3
  create_table :marginalia_books do |t|
4
4
  t.string :title
5
5
  t.string :format
6
- t.string :asin
7
- t.string :isbn
6
+ t.string :asin, index: { unique: true }
7
+ t.string :isbn, index: { unique: true }
8
8
  t.date :published_on
9
+ t.date :last_completed_on
9
10
  t.integer :pages
10
11
  t.integer :minutes
11
12
  t.integer :rating
12
- t.integer :read_count
13
13
  t.text :review
14
+ t.string :cover_url
15
+ t.boolean :library
14
16
 
15
17
  t.timestamps
16
18
  end
@@ -7,5 +7,6 @@ class CreateMarginaliaUpdates < ActiveRecord::Migration[7.0]
7
7
 
8
8
  t.timestamps
9
9
  end
10
+ add_index :marginalia_updates, [:book_id, :progress, :created_at], unique: true
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module Marginalia
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hearthside-marginalia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Hearth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-11 00:00:00.000000000 Z
11
+ date: 2023-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.4.1
172
+ rubygems_version: 3.4.10
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Reading tracking for Hearthside