From 61080a5188140df3dc8c9eb34b64dea9ebb384ea Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 14 Jun 2022 17:50:04 +0200 Subject: [PATCH] (feat) feature the first event --- Procfile | 2 +- app/frontend/src/javascript/controllers/events.js.erb | 6 ++++-- app/frontend/templates/events/index.html | 9 ++++++--- app/services/event_service.rb | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Procfile b/Procfile index 434aa4a6c..64f020c5e 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ -#web: bundle exec rails server puma -p $PORT +web: bundle exec rails server puma -p $PORT worker: bundle exec sidekiq -C ./config/sidekiq.yml webpack: bin/webpacker-dev-server diff --git a/app/frontend/src/javascript/controllers/events.js.erb b/app/frontend/src/javascript/controllers/events.js.erb index 16a3012b5..008c9a748 100644 --- a/app/frontend/src/javascript/controllers/events.js.erb +++ b/app/frontend/src/javascript/controllers/events.js.erb @@ -72,6 +72,7 @@ Application.Controllers.controller('EventsController', ['$scope', '$state', 'Eve // reinitialize results datasets $scope.page = 1; $scope.eventsGroupByMonth = {}; + $scope.featuredEevent = null; $scope.events = []; $scope.monthOrder = []; $scope.noMoreResults = false; @@ -111,13 +112,14 @@ Application.Controllers.controller('EventsController', ['$scope', '$state', 'Eve */ const groupEvents = function (events) { if (events.length > 0) { - const eventsGroupedByMonth = _.groupBy(events, function (obj) { + const eventsGroupedByMonth = _.groupBy(events.slice(1), function (obj) { return _.map(['month_id', 'year'], function (key) { return obj[key]; }); }); $scope.eventsGroupByMonth = Object.assign($scope.eventsGroupByMonth, eventsGroupedByMonth); - return $scope.monthOrder = Object.keys($scope.eventsGroupByMonth); + $scope.monthOrder = Object.keys($scope.eventsGroupByMonth); + $scope.featuredEevent = events[0]; } }; diff --git a/app/frontend/templates/events/index.html b/app/frontend/templates/events/index.html index 5b2f065f5..02b436682 100644 --- a/app/frontend/templates/events/index.html +++ b/app/frontend/templates/events/index.html @@ -40,9 +40,12 @@ -
- - +
+ +
diff --git a/app/services/event_service.rb b/app/services/event_service.rb index 6747aca36..860391532 100644 --- a/app/services/event_service.rb +++ b/app/services/event_service.rb @@ -37,8 +37,8 @@ class EventService start_at = DateTime.new(start_date.year, start_date.month, start_date.day, 0, 0, 0, start_date.zone) end_at = DateTime.new(end_date.year, end_date.month, end_date.day, 23, 59, 59, end_date.zone) else - start_at = DateTime.new(start_date.year, start_date.month, start_date.day, start_time.hour, start_time.min, start_time.sec, start_date.zone) - end_at = DateTime.new(end_date.year, end_date.month, end_date.day, end_time.hour, end_time.min, end_time.sec, end_date.zone) + start_at = DateTime.new(start_date.year, start_date.month, start_date.day, start_time&.hour, start_time&.min, start_time&.sec, start_date.zone) + end_at = DateTime.new(end_date.year, end_date.month, end_date.day, end_time&.hour, end_time&.min, end_time&.sec, end_date.zone) end { start_at: start_at, end_at: end_at } end