Class RecommendService

java.lang.Object
org.localify.recommend.RecommendService

@Service public class RecommendService extends Object
Service for handling recommendations.
  • Constructor Details

  • Method Details

    • saveRecommendation

      @Transactional public void saveRecommendation(UUID userId, UUID cityId, List<RecommendedArtistDto> res, List<UUID> seedList, UUID festivalId)
      Saves a recommendation for a user.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      res - The list of recommended artist DTOs.
      seedList - The list of seed artist IDs.
      festivalId - The ID of the festival.
    • getSeedsForUser

      public List<UUID> getSeedsForUser(UUID userId)
      Gets the seed artist IDs for a user.
      Parameters:
      userId - The ID of the user.
      Returns:
      A list of seed artist IDs.
    • cityRecommendFestivals

      public List<RecommendedCityFestivalDto> cityRecommendFestivals(UUID userId, UUID cityId)
      Recommends festivals for a user in a city.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      Returns:
      A list of recommended city festival DTOs.
    • festivalRecommend

      public List<RecommendedFestivalArtistDto> festivalRecommend(UUID userId, UUID festivalId)
      Recommends artists for a festival.
      Parameters:
      userId - The ID of the user.
      festivalId - The ID of the festival.
      Returns:
      A list of recommended festival artist DTOs.
    • performanceMatchesFilters

      public boolean performanceMatchesFilters(FestivalPerformance performance, List<LocalDate> dates, List<FestivalStage> stages, LocalTime startTime, LocalTime endTime)
      Checks if a performance matches the given filters.
      Parameters:
      performance - The performance to check.
      dates - The list of dates to filter by.
      stages - The list of stages to filter by.
      startTime - The start time to filter by.
      endTime - The end time to filter by.
      Returns:
      true if the performance matches the filters, false otherwise.
    • isFestivalRequested

      public boolean isFestivalRequested(UUID artistId, Map<UUID,List<FestivalPerformance>> artistPerformances, List<LocalDate> dates, List<FestivalStage> stages, LocalTime startTime, LocalTime endTime)
      Checks if an artist is requested for a festival based on the given filters.
      Parameters:
      artistId - The ID of the artist.
      artistPerformances - A map of artist IDs to their performances.
      dates - The list of dates to filter by.
      stages - The list of stages to filter by.
      startTime - The start time to filter by.
      endTime - The end time to filter by.
      Returns:
      true if the artist is requested, false otherwise.
    • orderPerformance

      public int orderPerformance(FestivalPerformance a, FestivalPerformance b, List<LocalDate> dates, List<FestivalStage> stages, LocalTime startTime, LocalTime endTime)
      Orders two performances based on the given filters.
      Parameters:
      a - The first performance.
      b - The second performance.
      dates - The list of dates to filter by.
      stages - The list of stages to filter by.
      startTime - The start time to filter by.
      endTime - The end time to filter by.
      Returns:
      A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
    • festivalRecommend

      public List<RecommendedFestivalArtistDto> festivalRecommend(UUID userId, UUID festivalId, List<LocalDate> dates, List<UUID> stageIds, LocalTime startTime, LocalTime endTime)
      Recommends artists for a festival.
      Parameters:
      userId - The ID of the user.
      festivalId - The ID of the festival.
      dates - The list of dates to filter by.
      stageIds - The list of stage IDs to filter by.
      startTime - The start time to filter by.
      endTime - The end time to filter by.
      Returns:
      A list of recommended festival artist DTOs.
    • cityRecommend

      public List<RecommendedArtistDto> cityRecommend(UUID userId, UUID cityId)
      Recommends artists for a city.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      Returns:
      A list of recommended artist DTOs.
    • recommend

      public List<RecommendedArtistDto> recommend(List<UUID> seedIds, List<UUID> candidateIds, UUID userId, UUID cityId, UUID festivalId)
      Gets recommendations for a user.
      Parameters:
      seedIds - The list of seed artist IDs.
      candidateIds - The list of candidate artist IDs.
      userId - The ID of the user.
      cityId - The ID of the city.
      festivalId - The ID of the festival.
      Returns:
      A list of recommended artist DTOs.
    • milesToMeters

      public static double milesToMeters(double miles)
      Converts miles to meters.
      Parameters:
      miles - The distance in miles.
      Returns:
      The distance in meters.
    • recommendEvents

      @Transactional public List<RecommendedEventDto> recommendEvents(UUID userId, UUID cityId)
      Recommends events for a user in a city.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      Returns:
      A list of recommended event DTOs.
    • recommendEvents

      @Transactional public List<RecommendedEventDto> recommendEvents(UUID userId, UUID cityId, RecSortSetting sortBy, CitySelectionTimeFrame timeFrame, Long cStart, Long cEnd)
      Recommends events for a user in a city.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      sortBy - The sorting setting.
      timeFrame - The time frame for events.
      cStart - The custom start time.
      cEnd - The custom end time.
      Returns:
      A list of recommended event DTOs.
    • recsplainsForArtist

      Converts a Recsplain object to a similar artist DTO.
      Parameters:
      recsplain - The Recsplain object.
      Returns:
      A similar artist DTO.
    • switchModel

      public void switchModel()
      Switches the model used by the recommender.
    • trainModel

      public void trainModel()
      Trains the recommender model.