Skip to content

Commit

Permalink
Merge pull request #222 from ThatConference/refactor/channel-create
Browse files Browse the repository at this point in the history
refactor: timing on open_space channel created vs batch created
  • Loading branch information
brettski authored Oct 31, 2023
2 parents 119afbb + 6c0fae1 commit 1f3b41d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "that-api-sessions",
"version": "4.5.0",
"version": "4.5.1",
"description": "THAT Conference Sessions Service.",
"main": "index.js",
"engines": {
Expand Down
25 changes: 6 additions & 19 deletions src/lib/__test__/findDateAtNextHour.test.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,36 @@
import { findDateAtNextHour } from '../findDateAtNextHour';
import dayjs from 'dayjs';
import mockDate from 'mockdate';

const tests = [
{
now: '2023-10-11T10:10:10',
for: 8,
expect: dayjs('2023-10-11T10:10:10')
.add(1, 'day')
.hour(8)
.startOf('hour')
.toDate(),
expect: new Date('2023-10-12T08:00:00'),
},
{
now: '2023-10-11T10:10:10',
for: 12,
expect: dayjs('2023-10-11T10:10:10').hour(12).startOf('hour').toDate(),
expect: new Date('2023-10-11T12:00:00'),
},
{
now: '2023-10-11T10:10:10',
for: 10,
expect: dayjs('2023-10-11T10:10:10')
.add(1, 'day')
.hour(10)
.startOf('hour')
.toDate(),
expect: new Date('2023-10-12T10:00:00'),
},
{
now: '2023-10-11T11:00:00',
for: 11,
expect: dayjs('2023-10-11T11:00:00').hour(11).startOf('hour').toDate(),
expect: new Date('2023-10-11T11:00:00'),
},
{
now: '2023-10-11T11:00:01',
for: 11,
expect: dayjs('2023-10-11T11:00:00')
.add(1, 'day')
.hour(11)
.startOf('hour')
.toDate(),
expect: new Date('2023-10-12T11:00:00'),
},
{
now: '2023-10-11T10:59:59',
for: 11,
expect: dayjs('2023-10-11T10:59:59').hour(11).startOf('hour').toDate(),
expect: new Date('2023-10-11T11:00:00'),
},
];

Expand Down
4 changes: 3 additions & 1 deletion src/lib/callThatJoinDiscordBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export function createVoiceChannelForSession({ session }) {
// startTime < time of next batch
// time of next batch (assuming batches are at 08:00)
const sessionStart = dayjs(session.startTime);
const nextBatchTime = dayjs(findDateAtNextHour(8));
let nextBatchTime = dayjs(findDateAtNextHour(8));
// skip to next batch so activities are listed longer (at least 24 hours)
nextBatchTime = nextBatchTime.add(1, 'day');
if (
session.status === 'ACCEPTED' &&
session.type === 'OPEN_SPACE' &&
Expand Down

0 comments on commit 1f3b41d

Please sign in to comment.