Package org.localify.recommend
Class RecommendService
java.lang.Object
org.localify.recommend.RecommendService
Service for handling recommendations.
-
Constructor Summary
ConstructorsConstructorDescriptionRecommendService(Recommender recommender, CityRepository cityRepository, ArtistRepository artistRepository, UserRepository userRepository, EventRepository eventRepository, GenreRepository genreRepository, UserFavoriteArtistRepository userFavoriteArtistRepository, UserFavoriteEventRepository userFavoriteEventRepository, ArtistService artistService, PointUtil pointUtil, UserCityRepository userCityRepository, UserRecommendationRepository userRecommendationRepository, UserArtistRecommendationRepository userArtistRecommendationRepository, UserRecommendationSimilarArtistRepository userRecommendationSimilarArtistRepository, ArtistCityRepository artistCityRepository, LocalifyProperties properties, PlaylistService playlistService, FestivalArtistRepository festivalArtistRepository, FestivalRepository festivalRepository, FestivalPerformanceRepository festivalPerformanceRepository, FestivalService festivalService, VenueRepository venueRepository, FestivalStageRepository festivalStageRepository) Constructs a new RecommendService. -
Method Summary
Modifier and TypeMethodDescriptioncityRecommend(UUID userId, UUID cityId) Recommends artists for a city.cityRecommendFestivals(UUID userId, UUID cityId) Recommends festivals for a user in a city.festivalRecommend(UUID userId, UUID festivalId) Recommends artists for a festival.festivalRecommend(UUID userId, UUID festivalId, List<LocalDate> dates, List<UUID> stageIds, LocalTime startTime, LocalTime endTime) Recommends artists for a festival.getSeedsForUser(UUID userId) Gets the seed artist IDs for a user.booleanisFestivalRequested(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.static doublemilesToMeters(double miles) Converts miles to meters.intorderPerformance(FestivalPerformance a, FestivalPerformance b, List<LocalDate> dates, List<FestivalStage> stages, LocalTime startTime, LocalTime endTime) Orders two performances based on the given filters.booleanperformanceMatchesFilters(FestivalPerformance performance, List<LocalDate> dates, List<FestivalStage> stages, LocalTime startTime, LocalTime endTime) Checks if a performance matches the given filters.Gets recommendations for a user.recommendEvents(UUID userId, UUID cityId) Recommends events for a user in a city.recommendEvents(UUID userId, UUID cityId, RecSortSetting sortBy, CitySelectionTimeFrame timeFrame, Long cStart, Long cEnd) Recommends events for a user in a city.Converts a Recsplain object to a similar artist DTO.voidsaveRecommendation(UUID userId, UUID cityId, List<RecommendedArtistDto> res, List<UUID> seedList, UUID festivalId) Saves a recommendation for a user.voidSwitches the model used by the recommender.voidTrains the recommender model.
-
Constructor Details
-
RecommendService
@Autowired public RecommendService(Recommender recommender, CityRepository cityRepository, ArtistRepository artistRepository, UserRepository userRepository, EventRepository eventRepository, GenreRepository genreRepository, UserFavoriteArtistRepository userFavoriteArtistRepository, UserFavoriteEventRepository userFavoriteEventRepository, ArtistService artistService, PointUtil pointUtil, UserCityRepository userCityRepository, UserRecommendationRepository userRecommendationRepository, UserArtistRecommendationRepository userArtistRecommendationRepository, UserRecommendationSimilarArtistRepository userRecommendationSimilarArtistRepository, ArtistCityRepository artistCityRepository, LocalifyProperties properties, PlaylistService playlistService, FestivalArtistRepository festivalArtistRepository, FestivalRepository festivalRepository, FestivalPerformanceRepository festivalPerformanceRepository, FestivalService festivalService, VenueRepository venueRepository, FestivalStageRepository festivalStageRepository) Constructs a new RecommendService.- Parameters:
recommender- The recommender engine.cityRepository- The city repository.artistRepository- The artist repository.userRepository- The user repository.eventRepository- The event repository.genreRepository- The genre repository.userFavoriteArtistRepository- The user favorite artist repository.userFavoriteEventRepository- The user favorite event repository.artistService- The artist service.pointUtil- The point utility.userCityRepository- The user city repository.userRecommendationRepository- The user recommendation repository.userArtistRecommendationRepository- The user artist recommendation repository.userRecommendationSimilarArtistRepository- The user recommendation similar artist repository.artistCityRepository- The artist city repository.properties- The application properties.playlistService- The playlist service.festivalArtistRepository- The festival artist repository.festivalRepository- The festival repository.festivalPerformanceRepository- The festival performance repository.festivalService- The festival service.venueRepository- The venue repository.festivalStageRepository- The festival stage repository.
-
-
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
Gets the seed artist IDs for a user.- Parameters:
userId- The ID of the user.- Returns:
- A list of seed artist IDs.
-
cityRecommendFestivals
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
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
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
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
public RecommendedArtistDto.SimilarArtistDto recsplainsForArtist(RecSysArtistResponse.Recsplain recsplain) 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.
-