Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Added possibility to create random voted talks
Browse files Browse the repository at this point in the history
  • Loading branch information
svenreimers committed Sep 30, 2023
1 parent ee57112 commit 2f5b3c0
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cinema/src/main/resources/tweetwall.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions cinema/src/main/resources/tweetwallConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
"amount": "15"
}
},
{
"stepClassName": "org.tweetwallfx.controls.steps.NodeFadeOutStep",
"config": {
"nodeSelector": "#topRatedToday"
}
},
{
"stepClassName": "org.tweetwallfx.conference.stepengine.steps.ShowSchedule",
"config": {
Expand Down Expand Up @@ -108,6 +114,12 @@
"unit": "SECONDS",
"amount": "15"
}
},
{
"stepClassName": "org.tweetwallfx.controls.steps.NodeFadeOutStep",
"config": {
"nodeSelector": "#topRatedWeek"
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.util.stream.Collectors;

import jakarta.ws.rs.core.GenericType;
import java.util.Random;
import java.util.random.RandomGenerator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -177,19 +179,36 @@ public Optional<RatingClient> getRatingClient() {

@Override
public List<RatedTalk> getRatedTalks(final String conferenceDay) {
return getVotingResults().entrySet().stream()
if (Boolean.getBoolean("org.tweetwallfx.conference.randomTalks")) {
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<RatedTalk> getRatedTalksOverall() {
return getVotingResults().entrySet().stream()
if (Boolean.getBoolean("org.tweetwallfx.conference.randomTalks")) {
return randomizedRatedTalks();
} else {
return getVotingResults().entrySet().stream()
.map(Map.Entry::getValue)
.flatMap(List::stream)
.toList();
}
}

private List<RatedTalk> randomizedRatedTalks() {
return RestCallHelper.readOptionalFrom(config.getEventBaseUri() + "talks", listOfMaps())
.orElse(List.of())
.stream()
.filter(talk -> RandomGenerator.getDefault().nextBoolean())
.map(this::convertTalkToRatedTalk)
.toList();
}

private Map<WeekDay, List<RatedTalk>> getVotingResults() {
Expand Down Expand Up @@ -228,6 +247,15 @@ private Map<WeekDay, List<RatedTalk>> convertTalkRatings(final Map<String, Objec
.toList()))));
}

private RatedTalk convertTalkToRatedTalk(final Map<String, Object> input) {
LOG.debug("Converting 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<String, Object> input) {
LOG.debug("Converting to RatedTalk: {}", input);
return RatedTalkImpl.builder()
Expand Down
2 changes: 1 addition & 1 deletion exhibition/src/main/resources/tweetwall.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion hallway/src/main/resources/tweetwall.css
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 2f5b3c0

Please sign in to comment.