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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b98b50a6ca98e477b3cd97aa98606246e4935394be67c9be2e34472a86be78c
4
- data.tar.gz: 8103fd914dba2b063cff762494f413d126ba3f89e4a82dfcf6193be18f6c8188
3
+ metadata.gz: 4f0e60cb65325e46bc4a3c6be6c4d92ea768f5fa8b3cf6d70a0739bee0973d6c
4
+ data.tar.gz: 3eb17cd0752508ff4569653d4b47ad3a2c99c9136813cf310e4d25c1bdb5ba64
5
5
  SHA512:
6
- metadata.gz: '091ca94de8f8e7cca4ede54545becac9a94119f2022ec8921f99e87fbd38ad1e4f85d666e23456cd05640c6046fd8af3bbbc1561b94a343f55f384ed9dc74304'
7
- data.tar.gz: 2ed32919986167cb101aa9a99108382ba2c7e3800aeb2bc04c9ee153f63246ad31fee02191a15003ac51cf532ee668f11d2f777feb1cf90406b54b249aa3c223
6
+ metadata.gz: 526d67d650f2af010a6f4dd1c28c74e4c35cb29f7d35d4b4e530656d96c85397ba12327a0758dc8c8153fd4119a9f88af5c3e6eabc275b281b99958990bfdf69
7
+ data.tar.gz: 69d6cf457fd5c4bfe144a74367d856b986e32e8785ef9aa5a55cec10cfcf901dd57f12379f4397fbc202796d87fa0444a6aa3c5a26471c5c4181291e20ef26f3
@@ -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["peopleLeft"] = peopleLeft
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
@@ -1,3 +1,3 @@
1
1
  module GTHC
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: gthc
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
  - Aman Ibrahim
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-12-02 00:00:00.000000000 Z
12
+ date: 2019-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler