<commit_before>package com.ashay.odc.roomer.service

import com.ashay.odc.roomer.domain.Booking
import com.ashay.odc.roomer.domain.Room
import com.ashay.odc.roomer.domain.Team
import com.ashay.odc.roomer.repositories.BookingsRepository
import com.ashay.odc.roomer.repositories.RoomsRepository
import com.ashay.odc.roomer.repositories.TeamsRepository
import org.joda.time.DateTime
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import org.springframework.util.StringUtils

@Service
class BookingService {

    @Autowired
    private final BookingsRepository bookingRepository

    public Booking book(Room room, Team team, Date startTime, int durationInMins) {

        if (bookingRepository.findByRoomAndEndTimeBetween(room, getStartTime(startTime), getEndTime(startTime, durationInMins)) ||
            bookingRepository.findByRoomAndStartTimeBetween(room, getStartTime(startTime), getEndTime(startTime, durationInMins))) {
            throw new RuntimeException("Booking Already exists!")
        }
        Booking booking = new Booking()
        booking.room = room
        booking.team = team
        booking.startTime = startTime
        booking.endTime = getEndTime(startTime, durationInMins)

        bookingRepository.save(booking)
    }

    public void cancel(Booking booking) {
        bookingRepository.delete(booking)
    }

    public List<Booking> getAllBookings(Room room) {
        if (room) {
            bookingRepository.findByRoom(room)
        } else {
            bookingRepository.findAll()
        }
    }

    private static def getEndTime(Date startTime, int durationInMins) {
        new DateTime(startTime).plusMinutes(--durationInMins).toDate()
    }

    private static def getStartTime(Date startTime) {
        new DateTime(startTime).minusMinutes(1).toDate()
    }
}<commit_msg>Modifications for better names to methods<commit_after>package com.ashay.odc.roomer.service

import com.ashay.odc.roomer.domain.Booking
import com.ashay.odc.roomer.domain.Room
import com.ashay.odc.roomer.domain.Team
import com.ashay.odc.roomer.repositories.BookingsRepository
import org.joda.time.DateTime
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service
class BookingService {

    @Autowired
    private final BookingsRepository bookingRepository

    public Booking book(Room room, Team team, Date startTime, int durationInMins) {

        if (bookingRepository.findByRoomAndEndTimeBetween(room, getLowerBound(startTime), getHigherBound(startTime, durationInMins))
                || bookingRepository.findByRoomAndStartTimeBetween(room, getLowerBound(startTime), getHigherBound(startTime, durationInMins))) {
            throw new RuntimeException("Booking Already exists!")
        }
        Booking booking = new Booking()
        booking.room = room
        booking.team = team
        booking.startTime = startTime
        booking.endTime = getHigherBound(startTime, durationInMins)

        bookingRepository.save(booking)
    }

    public void cancel(Booking booking) {
        bookingRepository.delete(booking)
    }

    public List<Booking> getAllBookings(Room room) {
        if (room) {
            bookingRepository.findByRoom(room)
        } else {
            bookingRepository.findAll()
        }
    }

    private static def getHigherBound(Date startTime, int durationInMins) {
        new DateTime(startTime).plusMinutes(--durationInMins).toDate()
    }

    private static def getLowerBound(Date startTime) {
        new DateTime(startTime).minusMinutes(1).toDate()
    }
}
{'fraction_non_alphanumeric': 0.08546303929651003, 'fraction_numerical': 0.0005496015388843089, 'mean_word_length': 3.5671267252195733, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4670154', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1048, 'n_words': 195}