Skip to content

Commit e914526

Browse files
committed
feat(sleeps): update create action to handle date as a hash and include sleep_type in serializer
fix(scripts): optimize bundle install command with parallel jobs
1 parent 927881a commit e914526

5 files changed

Lines changed: 33 additions & 54 deletions

File tree

Gemfile.lock

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ GEM
9090
base64 (0.3.0)
9191
bcrypt (3.1.20)
9292
benchmark (0.4.1)
93-
bigdecimal (3.2.3)
93+
bigdecimal (3.3.1)
9494
blueprinter (1.2.1)
9595
bootsnap (1.18.6)
9696
msgpack (~> 1.2)
@@ -162,21 +162,14 @@ GEM
162162
dry-inflector (~> 1.0)
163163
dry-logic (~> 1.4)
164164
zeitwerk (~> 2.6)
165-
erb (5.0.2)
165+
erb (5.0.3)
166166
erubi (1.13.1)
167167
factory_bot (6.5.5)
168168
activesupport (>= 6.1.0)
169169
factory_bot_rails (6.5.1)
170170
factory_bot (~> 6.5)
171171
railties (>= 6.1.0)
172-
ffi (1.17.2-aarch64-linux-gnu)
173-
ffi (1.17.2-aarch64-linux-musl)
174-
ffi (1.17.2-arm-linux-gnu)
175-
ffi (1.17.2-arm-linux-musl)
176172
ffi (1.17.2-arm64-darwin)
177-
ffi (1.17.2-x86_64-darwin)
178-
ffi (1.17.2-x86_64-linux-gnu)
179-
ffi (1.17.2-x86_64-linux-musl)
180173
flay (2.13.3)
181174
erubi (~> 1.10)
182175
path_expander (~> 1.0)
@@ -198,7 +191,7 @@ GEM
198191
pp (>= 0.6.0)
199192
rdoc (>= 4.0.0)
200193
reline (>= 0.4.2)
201-
json (2.15.0)
194+
json (2.15.1)
202195
jwt (3.1.2)
203196
base64
204197
language_server-protocol (3.17.0.5)
@@ -228,9 +221,9 @@ GEM
228221
net-smtp
229222
marcel (1.1.0)
230223
mini_mime (1.1.5)
231-
minitest (5.25.5)
224+
minitest (5.26.0)
232225
msgpack (1.8.0)
233-
net-imap (0.5.10)
226+
net-imap (0.5.12)
234227
date
235228
net-protocol
236229
net-pop (0.1.2)
@@ -240,22 +233,8 @@ GEM
240233
net-smtp (0.5.1)
241234
net-protocol
242235
nio4r (2.7.4)
243-
nokogiri (1.18.10-aarch64-linux-gnu)
244-
racc (~> 1.4)
245-
nokogiri (1.18.10-aarch64-linux-musl)
246-
racc (~> 1.4)
247-
nokogiri (1.18.10-arm-linux-gnu)
248-
racc (~> 1.4)
249-
nokogiri (1.18.10-arm-linux-musl)
250-
racc (~> 1.4)
251236
nokogiri (1.18.10-arm64-darwin)
252237
racc (~> 1.4)
253-
nokogiri (1.18.10-x86_64-darwin)
254-
racc (~> 1.4)
255-
nokogiri (1.18.10-x86_64-linux-gnu)
256-
racc (~> 1.4)
257-
nokogiri (1.18.10-x86_64-linux-musl)
258-
racc (~> 1.4)
259238
oj (3.16.11)
260239
bigdecimal (>= 3.0)
261240
ostruct (>= 0.2)
@@ -267,25 +246,19 @@ GEM
267246
ast (~> 2.4.1)
268247
racc
269248
path_expander (1.1.3)
270-
pg (1.6.2)
271-
pg (1.6.2-aarch64-linux)
272-
pg (1.6.2-aarch64-linux-musl)
273249
pg (1.6.2-arm64-darwin)
274-
pg (1.6.2-x86_64-darwin)
275-
pg (1.6.2-x86_64-linux)
276-
pg (1.6.2-x86_64-linux-musl)
277-
pp (0.6.2)
250+
pp (0.6.3)
278251
prettyprint
279252
prettyprint (0.2.0)
280-
prism (1.5.1)
253+
prism (1.5.2)
281254
psych (5.2.6)
282255
date
283256
stringio
284257
public_suffix (6.0.2)
285258
puma (7.0.4)
286259
nio4r (~> 2.0)
287260
racc (1.8.1)
288-
rack (3.2.2)
261+
rack (3.2.3)
289262
rack-cors (3.0.0)
290263
logger
291264
rack (>= 3.0.14)
@@ -331,9 +304,10 @@ GEM
331304
rb-fsevent (0.11.2)
332305
rb-inotify (0.11.1)
333306
ffi (~> 1.0)
334-
rdoc (6.14.2)
307+
rdoc (6.15.0)
335308
erb
336309
psych (>= 4.0.0)
310+
tsort
337311
reek (6.5.0)
338312
dry-schema (~> 1.13)
339313
logger (~> 1.6)
@@ -343,9 +317,9 @@ GEM
343317
regexp_parser (2.11.3)
344318
reline (0.6.2)
345319
io-console (~> 0.5)
346-
responders (3.1.1)
347-
actionpack (>= 5.2)
348-
railties (>= 5.2)
320+
responders (3.2.0)
321+
actionpack (>= 7.0)
322+
railties (>= 7.0)
349323
rexml (3.4.4)
350324
rspec-core (3.13.5)
351325
rspec-support (~> 3.13.0)
@@ -442,7 +416,7 @@ GEM
442416
unicode-emoji (~> 4.1)
443417
unicode-emoji (4.1.0)
444418
uniform_notifier (1.18.0)
445-
uri (1.0.3)
419+
uri (1.0.4)
446420
useragent (0.16.11)
447421
virtus (2.0.0)
448422
axiom-types (~> 0.1)
@@ -462,16 +436,7 @@ GEM
462436
zeitwerk (2.7.3)
463437

464438
PLATFORMS
465-
aarch64-linux
466-
aarch64-linux-gnu
467-
aarch64-linux-musl
468-
arm-linux-gnu
469-
arm-linux-musl
470-
arm64-darwin
471-
x86_64-darwin
472-
x86_64-linux
473-
x86_64-linux-gnu
474-
x86_64-linux-musl
439+
arm64-darwin-24
475440

476441
DEPENDENCIES
477442
blueprinter

app/controllers/api/v1/sleeps_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ def show
3030
end
3131

3232
def create
33-
sleep = Sleep.new(sleep_params.merge(user: current_user))
33+
date_hash = params[:sleep][:date]
34+
35+
timestamp = Time.zone.local(date_hash['year'], date_hash['month'], date_hash['day'])
36+
37+
sleep = Sleep.new(sleep_params.merge(user: current_user, date: timestamp))
38+
3439
if sleep.save
3540
render json: SleepSerializer.render(sleep, view: :index_and_create), status: :created
3641
else
@@ -71,6 +76,7 @@ def sleep_params
7176
:current_mood,
7277
:title,
7378
:updated_at,
79+
:sleep_type,
7480
:happened,
7581
{ tags_attributes: [tags_attributes] }
7682
])

bin/reset-db

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22
set -e
33

4-
bundle install
4+
MAKE="make --jobs $(nproc)" bundle install
55
bundle exec rails db:drop && rails db:create && rails db:migrate && rails db:seed

scripts/dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
(cd "$(pwd)/../pastel-api" \
4-
&& bundle install \
4+
&& MAKE="make --jobs $(nproc)" bundle install \
55
&& bundle exec rails db:migrate
66
)
77

spec/request/api/v1/sleeps_controller_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@
7676
let(:params) do
7777
{
7878
title: 'Great dream',
79-
date: Time.zone.today,
79+
date: {
80+
calendar: {
81+
identifier: 'gregory'
82+
},
83+
era: 'AD',
84+
year: 2025,
85+
month: 9,
86+
day: 30
87+
},
8088
description: 'Great description of my last night dream',
8189
current_mood: 'Good mood',
8290
intensity: Sleep::INTENSITY[Sleep::INTENSITY.keys.sample],

0 commit comments

Comments
 (0)