From 4bdfe5516fa3f6d3549b7d3f124c485d006781fd Mon Sep 17 00:00:00 2001 From: Sven Reimers Date: Sat, 30 Sep 2023 15:58:49 +0200 Subject: [PATCH] Added possibility to create random voted talks --- cinema/src/main/resources/tweetwall.css | 2 +- .../src/main/resources/tweetwallConfig.json | 12 +++++++ .../conference/impl/ConferenceClientImpl.java | 35 +++++++++++++++++-- exhibition/src/main/resources/tweetwall.css | 2 +- hallway/src/main/resources/tweetwall.css | 2 +- 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/cinema/src/main/resources/tweetwall.css b/cinema/src/main/resources/tweetwall.css index 9230924..f27f61b 100644 --- a/cinema/src/main/resources/tweetwall.css +++ b/cinema/src/main/resources/tweetwall.css @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2013 TweetWallFX + * Copyright (c) 2023 TweetWallFX * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cinema/src/main/resources/tweetwallConfig.json b/cinema/src/main/resources/tweetwallConfig.json index 17690a8..f03fd7e 100644 --- a/cinema/src/main/resources/tweetwallConfig.json +++ b/cinema/src/main/resources/tweetwallConfig.json @@ -58,6 +58,12 @@ "amount": "15" } }, + { + "stepClassName": "org.tweetwallfx.controls.steps.NodeFadeOutStep", + "config": { + "nodeSelector": "#topRatedToday" + } + }, { "stepClassName": "org.tweetwallfx.conference.stepengine.steps.ShowSchedule", "config": { @@ -108,6 +114,12 @@ "unit": "SECONDS", "amount": "15" } + }, + { + "stepClassName": "org.tweetwallfx.controls.steps.NodeFadeOutStep", + "config": { + "nodeSelector": "#topRatedWeek" + } } ] } diff --git a/conference-impl/src/main/java/org/tweetwallfx/conference/impl/ConferenceClientImpl.java b/conference-impl/src/main/java/org/tweetwallfx/conference/impl/ConferenceClientImpl.java index 98af9e1..de87712 100644 --- a/conference-impl/src/main/java/org/tweetwallfx/conference/impl/ConferenceClientImpl.java +++ b/conference-impl/src/main/java/org/tweetwallfx/conference/impl/ConferenceClientImpl.java @@ -32,8 +32,10 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Random; import java.util.function.Consumer; import java.util.function.Function; +import java.util.random.RandomGenerator; import java.util.stream.Collectors; import jakarta.ws.rs.core.GenericType; @@ -177,19 +179,39 @@ public Optional getRatingClient() { @Override public List getRatedTalks(final String conferenceDay) { - return getVotingResults().entrySet().stream() + if (Boolean.getBoolean("org.tweetwallfx.conference.randomTalks")) { + System.out.println("######## randomizedRatedTalksPerDay"); + return randomizedRatedTalks(); + } else { + return getVotingResults().entrySet().stream() .filter(e -> e.getKey().dayId().equals(conferenceDay)) .map(Map.Entry::getValue) .findFirst() .orElse(List.of()); + } } @Override public List getRatedTalksOverall() { - return getVotingResults().entrySet().stream() + if (Boolean.getBoolean("org.tweetwallfx.conference.randomTalks")) { + System.out.println("######## randomizedRatedTalksWeek"); + return randomizedRatedTalks(); + } else { + return getVotingResults().entrySet().stream() .map(Map.Entry::getValue) .flatMap(List::stream) .toList(); + } + } + + private List randomizedRatedTalks() { + System.out.println("######## randomizedRatedTalks"); + return RestCallHelper.readOptionalFrom(config.getEventBaseUri() + "talks", listOfMaps()) + .orElse(List.of()) + .stream() + .filter(talk -> RandomGenerator.getDefault().nextBoolean()) + .map(this::convertTalkToRatedTalk) + .toList(); } private Map> getVotingResults() { @@ -228,6 +250,15 @@ private Map> convertTalkRatings(final Map input) { + LOG.debug("Converting Talk to RatedTalk: {}", input); + return RatedTalkImpl.builder() + .withAverageRating(RandomGenerator.getDefault().nextDouble(5)) + .withTotalRating(RandomGenerator.getDefault().nextInt(200)) + .withTalk(convertTalk(input)) + .build(); + } + private RatedTalk convertRatedTalk(final Map input) { LOG.debug("Converting to RatedTalk: {}", input); return RatedTalkImpl.builder() diff --git a/exhibition/src/main/resources/tweetwall.css b/exhibition/src/main/resources/tweetwall.css index a2f0e76..494ab4f 100644 --- a/exhibition/src/main/resources/tweetwall.css +++ b/exhibition/src/main/resources/tweetwall.css @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2013 TweetWallFX + * Copyright (c) 2023 TweetWallFX * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/hallway/src/main/resources/tweetwall.css b/hallway/src/main/resources/tweetwall.css index 7133125..bb9b852 100644 --- a/hallway/src/main/resources/tweetwall.css +++ b/hallway/src/main/resources/tweetwall.css @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2013 TweetWallFX + * Copyright (c) 2023 TweetWallFX * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal