espace_membre-ruby 0.3 → 0.4

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
  SHA256:
3
- metadata.gz: 3a41c0eb438795538388c72ba30b3a811ed738679dd3513829b7975b31031ba9
4
- data.tar.gz: 7eef73ce9bf3bf3633ff8fb7ac69e6cf38c11b632dfa8d571c5aaa7463cf5309
3
+ metadata.gz: 39c15979e242f994f2e4e24dd4172df5580474880076dcb0dcdde4a35de7356c
4
+ data.tar.gz: f49d47e2527fbc5000dc867ddd6e9365493b10a170ff1d8bee58fa5e5089432f
5
5
  SHA512:
6
- metadata.gz: f44933d31ec69dc7b1187e6a07e99f6bfdcd4464b10e091f13465e0f669823dc0a5410a2076f02a73642a9618b4c973dc1334409f330141ddd0c9a7d220d9f62
7
- data.tar.gz: 3c986db86cbbfc3d65dc6378dcb48ad2d9457276ea81031a695b952817cf58cb076d81e42b660c41ea8dc209a517173873188d1aaddaf6e443f4562805810aaf
6
+ metadata.gz: ff0a7c8236eefc19c582e4b536e6b0a4ff58b5405a9b604a358b0ee53e92ec2e7fd15626987b4ed69591eb1591de0d88f60834326dadc0640377e0787ade73e7
7
+ data.tar.gz: 39cb9439a25d65e326ee9d6ccb380df56403e5e8a9409f5f6fcf965cb93f20f434c95a9caf019f66f09088819c7f0e10534408e13075b0014735a9839f409ecd
@@ -11,7 +11,11 @@ module EspaceMembre
11
11
  "transfer"
12
12
  ]
13
13
 
14
- scope :active, -> { where("end" => nil) }
14
+ # FIXME: at the moment multiple ongoing/active (i.e no end date)
15
+ # phases for the same startup can coexist happily, we must fix the
16
+ # data and make this a valid statement.
17
+ #
18
+ # scope :active, -> { where("end" => nil) } # this does NOT work
15
19
 
16
20
  PHASES.each do |phase|
17
21
  # define scopes for each state (Phase.success, Phase.alumni, etc.)
@@ -19,7 +19,17 @@ module EspaceMembre
19
19
  class_name: "Phase",
20
20
  inverse_of: :startup
21
21
 
22
- scope :in_phase, ->(*phase) { joins(:phases).merge(Phase.active).where("phases.name" => phase) }
22
+ # we must use this tragic hack because a startup can have one or
23
+ # more phases without an 'end' timestamp, which is wrong and
24
+ # misleading but that's how the data exists. So instead of
25
+ # assuming 'phase.end = nil' designates the active and latest
26
+ # phase, we have to always look at which one startet
27
+ # last.
28
+ scope :in_phase, ->(*phase) {
29
+ joins(:phases)
30
+ .where(phases: { name: phase })
31
+ .where("phases.start = (SELECT MAX(p2.start) FROM phases p2 WHERE p2.startup_id = startups.uuid)")
32
+ }
23
33
 
24
34
  Phase::PHASES.each do |name|
25
35
  define_method "in_#{name}?" do
@@ -1,3 +1,3 @@
1
1
  module EspaceMembre
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: espace_membre-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stéphane Maniaci