gthc 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gthc/olson/algorithm.rb +32 -2
- data/lib/gthc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f0e60cb65325e46bc4a3c6be6c4d92ea768f5fa8b3cf6d70a0739bee0973d6c
|
4
|
+
data.tar.gz: 3eb17cd0752508ff4569653d4b47ad3a2c99c9136813cf310e4d25c1bdb5ba64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 526d67d650f2af010a6f4dd1c28c74e4c35cb29f7d35d4b4e530656d96c85397ba12327a0758dc8c8153fd4119a9f88af5c3e6eabc275b281b99958990bfdf69
|
7
|
+
data.tar.gz: 69d6cf457fd5c4bfe144a74367d856b986e32e8785ef9aa5a55cec10cfcf901dd57f12379f4397fbc202796d87fa0444a6aa3c5a26471c5c4181291e20ef26f3
|
data/lib/gthc/olson/algorithm.rb
CHANGED
@@ -140,9 +140,39 @@ module Algorithm
|
|
140
140
|
combinedGrid.each do | slot |
|
141
141
|
peopleNeeded = Helpers.calculatePeopleNeeded slot[:isNight], slot[:phase]
|
142
142
|
peopleLeft = peopleNeeded - slot[:ids].length
|
143
|
-
slot[
|
143
|
+
slot[:peopleLeft] = peopleLeft
|
144
144
|
end
|
145
145
|
|
146
|
-
combinedGrid
|
146
|
+
return combinedGrid, simplifyGrid(combinedGrid)
|
147
147
|
end
|
148
|
+
|
149
|
+
def simplifyGrid(combinedGrid)
|
150
|
+
simplifiedGrid = []
|
151
|
+
currentSlot = {}
|
152
|
+
building = false
|
153
|
+
combinedGrid.each_with_index do |slot, index|
|
154
|
+
if building
|
155
|
+
#if a slot has already started building
|
156
|
+
if isConnectedSlot(currentSlot, slot)
|
157
|
+
currentSlot[:endDate] = slot[:endDate]
|
158
|
+
#if any of the slots are night, all are marked as night
|
159
|
+
currentSlot[:isNight] = true if slot[:isNight]
|
160
|
+
else
|
161
|
+
simplifiedGrid.push currentSlot
|
162
|
+
currentSlot = slot
|
163
|
+
end
|
164
|
+
else
|
165
|
+
# if are starting a new slot
|
166
|
+
currentSlot = slot
|
167
|
+
building = true
|
168
|
+
end
|
169
|
+
simplifiedGrid.push currentSlot if index == combinedGrid.length - 1
|
170
|
+
end
|
171
|
+
simplifiedGrid
|
172
|
+
end
|
173
|
+
|
174
|
+
def isConnectedSlot(slot1, slot2)
|
175
|
+
slot1[:ids] == slot2[:ids] and slot1[:phase] == slot2[:phase]
|
176
|
+
end
|
177
|
+
|
148
178
|
end
|
data/lib/gthc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gthc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Ibrahim
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-12-
|
12
|
+
date: 2019-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|