eve_app 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d05354a6b51bf892ac1f934455446366b5c7083
4
- data.tar.gz: 1f472b9deedc54d2f84fc30c069f59d64e2415c5
3
+ metadata.gz: bb760ef4fecf0ffb483d49c1615320b78dce3cb0
4
+ data.tar.gz: 72a2ab7abd782b83878bdf929fd2d1e52601db0d
5
5
  SHA512:
6
- metadata.gz: 33448204b634a96ae2c566e07b38e03b2c14113d85b315953f8ca6d45c5cc59c4bd3a098162760290d58b23ce33a80a30c9bc573a527e0faa6550f41933777c6
7
- data.tar.gz: 54eeaf33cc346fde27b376aa4f3e5d4bbad1a59bc249b0a5f18711104885695241d58238f22e7b40cc7303ccb41422bf15a292afa0d6fb563b7b4fec77e581e6
6
+ metadata.gz: 1ed8aef9695d7a58e8a2738dc842b0be74249d7250f2a71b93749cce2ee98ca355de54d79971dc5809e7cc3713d83675f5e579489e233cbb203b90294d46b739
7
+ data.tar.gz: a4e3bdb9756829f3e80772e277c7a41f5947863d38a7944a537994916eebf77f893cebc9fc981a3a79f2fa7ad916baa1ae23cf18738d7e10eca1e7222fcebd8a
@@ -5,22 +5,24 @@ module EveApp::ActivityRelation
5
5
  belongs_to :type
6
6
  belongs_to :activity
7
7
 
8
- # scope :invention, -> { where(activity_id: EveApp::Activity::INVENTION) }
9
- scope :for, -> (tid, aid) { where(type_id: tid, activity_id: aid) }
10
- scope :order_by_name, -> {
11
- includes(type_name).order('types.name')
12
- }
8
+ EveApp::Activity::TYPE_MAP.each do |id, type|
9
+ scope type, -> { where(activity_id: id) }
10
+ end
11
+ end
13
12
 
13
+ # included do
14
+ # scope :invention, -> { where(activity_id: EveApp::Activity::INVENTION) }
15
+ # scope :for, -> (tid, aid) { where(type_id: tid, activity_id: aid) }
14
16
  # ????
15
17
  # def activity_activity
16
18
  # EveApp::Activity.where(type_id: type_id, activity_id: activity_id)
17
19
  # end
18
- end
20
+ # end
19
21
 
20
- class_methods do
21
- def type_name
22
- reflections = self.reflect_on_all_associations(:belongs_to)
23
- reflections.select { |r| r.options[:class_name] == 'Type' && r.name != :type }.first.name
24
- end
25
- end
22
+ # class_methods do
23
+ # def type_name
24
+ # reflections = self.reflect_on_all_associations(:belongs_to)
25
+ # reflections.select { |r| r.options[:class_name] == 'Type' && r.name != :type }.first.name
26
+ # end
27
+ # end
26
28
  end
@@ -1,7 +1,7 @@
1
1
  class EveApp::ActivityMaterial < EveApp::ApplicationRecord
2
2
  include EveApp::ActivityRelation
3
3
 
4
- belongs_to :material, class_name: 'EveApp::Type', foreign_key: :material_type_id
4
+ belongs_to :material_type, class_name: 'EveApp::Type', foreign_key: :material_type_id
5
5
 
6
6
  scope :order_by_quantity, -> { order(quantity: :desc) }
7
7
 
@@ -1,8 +1,8 @@
1
1
  class EveApp::ActivityProduct < EveApp::ApplicationRecord
2
- include EveApp::ActivityRelation
2
+ belongs_to :type
3
+ belongs_to :product_type, class_name: 'EveApp::Type', foreign_key: :product_type_id
3
4
 
4
- belongs_to :activity_product, class_name: 'EveApp::Type', foreign_key: :product_type_id
5
-
6
- scope :invention, -> { where(activity_id: EveApp::Activity::INVENTION) }
7
- scope :manufacture, -> { where(activity_id: EveApp::Activity::MANUFACTURE) }
5
+ EveApp::Activity::TYPE_MAP.each do |id, type|
6
+ scope type, -> { where(activity_id: id) }
7
+ end
8
8
  end
@@ -3,8 +3,12 @@ class EveApp::Type < EveApp::ApplicationRecord
3
3
  belongs_to :group
4
4
  belongs_to :market_group
5
5
  belongs_to :market_group_root, class_name: 'EveApp::MarketGroup'
6
+ belongs_to :blueprint_type, class_name: 'EveApp::Type', optional: true
6
7
 
7
- has_many :activity_products
8
+ has_one :manufacture_product, -> { manufacture }, class_name: 'EveApp::ActivityProduct'
9
+ has_one :manufacture_product_type, through: :manufacture_product, source: :product_type
10
+
11
+ has_many :activity_materials
8
12
 
9
13
  scope :published, -> { where(published: true) }
10
14
 
@@ -52,10 +52,12 @@ module EveApp
52
52
  sql %Q(ALTER TABLE #{table_list['invTypes']} ADD IF NOT EXISTS market_group_name character varying)
53
53
  sql %Q(ALTER TABLE #{table_list['invMarketGroups']} ADD root_group_id INTEGER DEFAULT NULL)
54
54
  sql %Q(ALTER TABLE #{table_list['invTypes']} ADD market_group_root_id integer)
55
+ sql %Q(ALTER TABLE #{table_list['invTypes']} ADD blueprint_type_id integer)
55
56
  sql %Q(UPDATE #{table_list['invTypes']} SET group_name = (SELECT name FROM #{table_list['invGroups']} WHERE id = #{table_list['invTypes']}.group_id))
56
57
  sql %Q(UPDATE #{table_list['invTypes']} SET category_id = (SELECT category_id FROM #{table_list['invGroups']} WHERE id = #{table_list['invTypes']}.group_id))
57
58
  sql %Q(UPDATE #{table_list['invTypes']} SET category_name = (SELECT name FROM #{table_list['invCategories']} WHERE id = #{table_list['invTypes']}.category_id))
58
59
  sql %Q(UPDATE #{table_list['invTypes']} SET market_group_name = (SELECT name FROM #{table_list['invMarketGroups']} WHERE id = #{table_list['invTypes']}.market_group_id))
60
+ sql %Q(UPDATE #{table_list['invTypes']} SET blueprint_type_id = (SELECT type_id FROM #{table_list['industryActivityProducts']} WHERE activity_id = 1 AND product_type_id = #{table_list['invTypes']}.id LIMIT 1))
59
61
 
60
62
  sql %Q(
61
63
  WITH RECURSIVE mg_roots(id, root_id) AS (
@@ -1,3 +1,3 @@
1
1
  module EveApp
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eve_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Hiemstra