now i just need the new machine to install everything for deloyment
This commit is contained in:
parent
3730230925
commit
5c589a82f6
@ -24,7 +24,7 @@ public class DBCPDataSource {
|
||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||
ds.setUrl("jdbc:mysql://151.80.230.149:3306/unloze_racetimer_css?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUsername("unloze_racetimer_css");
|
||||
ds.setPassword("ahsdbahb/#¤FHdasd");
|
||||
ds.setPassword("dfhasFEb234dfsnFEEJSfFEJdfap");
|
||||
ds.setMaxTotal(-1);
|
||||
ds.setMinIdle(5);
|
||||
ds.setMaxIdle(-1);
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package facade;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class CallableJsonObject implements Callable<Map.Entry<String, String>> {
|
||||
|
||||
private JSONObject jsonObject;
|
||||
private String avatar;
|
||||
private String steamID;
|
||||
|
||||
public CallableJsonObject(JSONObject jsonObject) {
|
||||
String steamID64 = jsonObject.getString("steamid");
|
||||
this.avatar = jsonObject.getString("avatarfull");
|
||||
this.steamID = convertCommunityIdToSteamId(Long.valueOf(steamID64));
|
||||
}
|
||||
|
||||
public CallableJsonObject() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map.Entry<String, String> call() throws Exception {
|
||||
Map.Entry<String, String> entry = new AbstractMap.SimpleEntry<String, String>(steamID, avatar);
|
||||
return entry;
|
||||
}
|
||||
|
||||
private String convertCommunityIdToSteamId(long communityId) {
|
||||
long steamId1 = communityId % 2;
|
||||
long steamId2 = communityId - 76561197960265728L;
|
||||
steamId2 = (steamId2 - steamId1) / 2;
|
||||
return "STEAM_0:" + steamId1 + ":" + steamId2;
|
||||
}
|
||||
|
||||
}
|
@ -24,9 +24,14 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
@ -47,6 +52,13 @@ public class Facade {
|
||||
private final long EXPIRE_TIME_IN_SECONDS = TimeUnit.SECONDS.convert(30, TimeUnit.MINUTES);
|
||||
private Instant elapsedTime;
|
||||
private int initSetup = 0;
|
||||
private static final ForkJoinPool executor = instantiateExecutor();
|
||||
|
||||
private static ForkJoinPool instantiateExecutor() {
|
||||
return new ForkJoinPool(Runtime.getRuntime().availableProcessors(),
|
||||
ForkJoinPool.defaultForkJoinWorkerThreadFactory,
|
||||
null, false);
|
||||
}
|
||||
|
||||
public Facade() {
|
||||
elapsedTime = Instant.now();
|
||||
@ -311,31 +323,27 @@ public class Facade {
|
||||
}
|
||||
}
|
||||
|
||||
private String convertCommunityIdToSteamId(long communityId) {
|
||||
long steamId1 = communityId % 2;
|
||||
long steamId2 = communityId - 76561197960265728L;
|
||||
steamId2 = (steamId2 - steamId1) / 2;
|
||||
return "STEAM_0:" + steamId1 + ":" + steamId2;
|
||||
}
|
||||
|
||||
private void retrieveAvatarFull(String avatarurl) {
|
||||
try {
|
||||
Callable<Entry<String, String>> worker;
|
||||
final ConcurrentMap<Integer, Future<Entry<String, String>>> futures = new MapMaker().concurrencyLevel(6).makeMap();
|
||||
URL url = new URL(avatarurl);
|
||||
JSONTokener tokener = new JSONTokener(url.openStream());
|
||||
JSONObject root = new JSONObject(tokener);
|
||||
JSONObject jsonObject = root.getJSONObject("response");
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("players");
|
||||
for (int incrementer = 0; incrementer < jsonArray.length(); incrementer++) {
|
||||
try {
|
||||
String steamID64 = jsonArray.getJSONObject(incrementer).getString("steamid");
|
||||
String avatar = jsonArray.getJSONObject(incrementer).getString("avatarfull");
|
||||
String steamID = convertCommunityIdToSteamId(Long.valueOf(steamID64));
|
||||
playerCache.get(steamID).setAvatar(avatar);
|
||||
//System.out.println("avatar: " + avatar + "\nname: " + playerCache.get(steamID).getName() + "\n");
|
||||
} catch (NumberFormatException | JSONException ex) {
|
||||
System.out.println("ex: " + ex.getLocalizedMessage() + "\n Nosteamer");
|
||||
}
|
||||
worker = new CallableJsonObject(jsonArray.getJSONObject(incrementer));
|
||||
futures.put(incrementer, executor.submit(worker));
|
||||
}
|
||||
futures.values().parallelStream().forEach(future -> {
|
||||
try {
|
||||
Entry<String, String> getEntry = future.get(3, TimeUnit.SECONDS);
|
||||
playerCache.get(getEntry.getKey()).setAvatar(getEntry.getValue());
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
|
||||
Logger.getLogger(Facade.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException ex) {
|
||||
Logger.getLogger(Facade.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
@ -349,7 +357,8 @@ public class Facade {
|
||||
avatarURL.append("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=262F3F0C6B83E0F263C272C3762002F1&steamids=");
|
||||
int incrementer = 0;
|
||||
int overallCounter = 0;
|
||||
int fetchCapacity = 450;
|
||||
int fetchCapacity = players.size() > 5 ? players.size() / 5 : 6;
|
||||
CountDownLatch cdl = new CountDownLatch(1);
|
||||
for (Player player : players) {
|
||||
if (incrementer > 0) {
|
||||
avatarURL.append(",");
|
||||
@ -358,13 +367,25 @@ public class Facade {
|
||||
avatarURL.append(Long.toString(convertSteamIdToCommunityId(player.getSteamID())));
|
||||
if (incrementer >= fetchCapacity || incrementer + overallCounter >= players.size()) {
|
||||
final String fullUrl = avatarURL.toString();
|
||||
retrieveAvatarFull(fullUrl);
|
||||
final int overall = incrementer + overallCounter;
|
||||
new Thread(() -> {
|
||||
retrieveAvatarFull(fullUrl);
|
||||
if (overall >= players.size()) {
|
||||
cdl.countDown();
|
||||
}
|
||||
}).start();
|
||||
overallCounter += incrementer;
|
||||
incrementer = 0;
|
||||
avatarURL = new StringBuilder();
|
||||
avatarURL.append("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=262F3F0C6B83E0F263C272C3762002F1&steamids=");
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
cdl.await();
|
||||
} catch (InterruptedException ex) {
|
||||
System.out.println("cdl await interrupted: " + ex.getLocalizedMessage() + "\n");
|
||||
}
|
||||
setNonExistingAvatarOnPlayers(players);
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,9 @@ class Leaderboard extends React.Component {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{!this.state.breakload ? <h1>
|
||||
Loading Maps <br /> <br /> <br /> <LoadingIndicator />
|
||||
</h1> : ""}
|
||||
{this.state.searchBool ? ("") : (<PlayersSearch keyword={this.state.keyword} />)}
|
||||
<div className="container mm">
|
||||
<div className="row">
|
||||
@ -157,9 +160,6 @@ class Leaderboard extends React.Component {
|
||||
</div> </div>
|
||||
))}
|
||||
</div> </div>
|
||||
{!this.state.breakload ? <h1>
|
||||
Loading Players <br /> <br /> <br /> <LoadingIndicator />
|
||||
</h1> : ""}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
@ -96,6 +96,9 @@ class MapBoards extends React.Component {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{!this.state.breakload ? <h1>
|
||||
Loading Maps <br /> <br /> <br /> <LoadingIndicator />
|
||||
</h1> : ""}
|
||||
{this.state.searchBool ? ("") : (<MapsSearch keyword={this.state.keyword} />)}
|
||||
<div className="container mm" style={{ marginTop: "85px" }}>
|
||||
<div className="row">
|
||||
@ -103,22 +106,19 @@ class MapBoards extends React.Component {
|
||||
<div className="item" key={"mapdivs/" + e.mapname + "/" + e.mapstage}>
|
||||
<div className="box_grid">
|
||||
<li key={e.mapname + "/" + e.mapstage} id={"maps/" + e.mapname + "/" + e.mapstage}>
|
||||
|
||||
<NavLink to={'/map/' + e.mapname + "/" + e.mapstage}>
|
||||
<strong className="col-lg-1 col-centered" /> Map: {e.mapname}<br />
|
||||
<strong className="col-lg-1 col-centered" /> Stage: {e.mapstage}<br />
|
||||
<br />
|
||||
<br />
|
||||
</NavLink>
|
||||
|
||||
|
||||
<NavLink to={'/map/' + e.mapname + "/" + e.mapstage}>
|
||||
<strong className="col-lg-1 col-centered" /> Map: {e.mapname}<br />
|
||||
<strong className="col-lg-1 col-centered" /> Stage: {e.mapstage}<br />
|
||||
<br />
|
||||
<br />
|
||||
</NavLink>
|
||||
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{!this.state.breakload ? <h1>
|
||||
Loading Maps <br /> <br /> <br /> <LoadingIndicator />
|
||||
</h1> : ""}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
@ -80,29 +80,34 @@ class Maps extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="alert alert-primary" >
|
||||
<div id='containerMaps'>
|
||||
<div>
|
||||
<NavLink to={'/leaderboard/'}>
|
||||
<h3> <strong className="col-lg-1 col-centered" /> leaderboard<br /> </h3>
|
||||
</NavLink>
|
||||
<section className="hero_single version_2 start_bg_zoom">
|
||||
<div className="wrapper">
|
||||
<div className="container">
|
||||
<h3>Map: {this.state.mapName}</h3>
|
||||
<p>
|
||||
Stage: {this.props.match.params.stage}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
</section>
|
||||
<div className="tickets-block" style={{ background_color: "#393f47" }}>
|
||||
<div className="container-fluid">
|
||||
<p className="text-center ">
|
||||
<NavLink to={'/mapboard/'}>
|
||||
<h3> <strong className="col-lg-1 col-centered" /> MapBoard<br /> </h3>
|
||||
<b>MapBoard</b>
|
||||
</NavLink>
|
||||
</div>
|
||||
</p>
|
||||
<p className="text-center ">
|
||||
<NavLink to={'/leaderboard/'}>
|
||||
<b>leaderboard</b>
|
||||
</NavLink>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="container mm">
|
||||
<div style={{
|
||||
position: 'absolute', left: '50%', top: '30%'
|
||||
}}>
|
||||
<h2> <strong className="col-lg-1 col-centered" />{this.state.mapName}<br /> </h2>
|
||||
<br />
|
||||
<br />
|
||||
<div className="row">
|
||||
{this.state.mapTimes.map(e => (
|
||||
<li key={e.steamID} id={"maps/" + e.steamID}>
|
||||
<div className="item" key={e.steamID} id={"maps/" + e.steamID}>
|
||||
<div className="box_grid">
|
||||
<NavLink to={'/player/' + e.steamID}>
|
||||
<strong className="col-lg-1 col-centered" /> SteamID: {e.steamID}<br />
|
||||
@ -116,16 +121,14 @@ class Maps extends React.Component {
|
||||
<div key={e.badgesUrls[badges]}>
|
||||
<img src={e.badgesUrls[badges]} alt="" /> <br />
|
||||
</div>
|
||||
|
||||
))}
|
||||
<br />
|
||||
<br />
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
))}
|
||||
{!this.state.breakload ? <h1>
|
||||
Loading Players <br /> <br /> <LoadingIndicator />
|
||||
</h1> : ""}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
|
@ -49,13 +49,13 @@ class Player extends React.Component {
|
||||
window.removeEventListener("scroll", this.scrollListener);
|
||||
}
|
||||
|
||||
findSecondLast(array) {
|
||||
return array[array.length - 2];
|
||||
findLateIndex(array) {
|
||||
return array[array.length - 5];
|
||||
}
|
||||
|
||||
handleScroll = () => {
|
||||
if (this.state.breakload && this.state.player.Times > this.state.mapTimes.length) {
|
||||
const map = this.findSecondLast(this.state.mapTimes);
|
||||
const map = this.findLateIndex(this.state.mapTimes);
|
||||
var lastLi = document.getElementById("playermaps/" + map.mapname + "/" + map.mapstage);
|
||||
var lastLiOffset = lastLi.offsetTop + lastLi.clientHeight;
|
||||
var pageOffset = window.pageYOffset + window.innerHeight;
|
||||
@ -84,38 +84,43 @@ class Player extends React.Component {
|
||||
));
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="alert alert-primary" >
|
||||
<div id='containerMaps'>
|
||||
<div>
|
||||
<NavLink to={'/leaderboard/'}>
|
||||
<h3> <strong className="col-lg-1 col-centered" /> leaderboard<br /> </h3>
|
||||
</NavLink>
|
||||
</div>
|
||||
<div>
|
||||
<NavLink to={'/mapboard/'}>
|
||||
<h3> <strong className="col-lg-1 col-centered" /> MapBoard<br /> </h3>
|
||||
</NavLink>
|
||||
<section className="hero_single version_2 start_bg_zoom">
|
||||
<div className="wrapper">
|
||||
<div className="container">
|
||||
<h3>Player Profile: {this.state.player.name}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div className="tickets-block" style={{ background_color: "#393f47" }}>
|
||||
<div className="container-fluid">
|
||||
<p className="text-center ">
|
||||
<NavLink to={'/mapboard/'}>
|
||||
<b>MapBoard</b>
|
||||
</NavLink>
|
||||
</p>
|
||||
<p className="text-center ">
|
||||
<NavLink to={'/leaderboard/'}>
|
||||
<b>leaderboard</b>
|
||||
</NavLink>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="container mm" style={{ marginTop: "85px" }}>
|
||||
<div style={{
|
||||
position: 'absolute', left: '50%', top: '30%'
|
||||
}}>
|
||||
<div>
|
||||
<a href={"http://steamcommunity.com/profiles/" + this.state.player.steamID64}>
|
||||
<strong className="col-lg-1 col-centered" /> {this.state.player.steamID}<br />
|
||||
<strong className="col-lg-1 col-centered" />{this.state.player.name}<br />
|
||||
<img src={this.state.player.Avatar} alt="" /> <br />
|
||||
<strong className="col-lg-1 col-centered" />Rank: {this.state.player.Rank}<br />
|
||||
<strong className="col-lg-1 col-centered" />Points: {this.state.player.PlayerPoints}<br />
|
||||
<strong className="col-lg-1 col-centered" />Times: {this.state.player.Times}<br />
|
||||
{badges}
|
||||
<br />
|
||||
<br />
|
||||
</a>
|
||||
{this.state.mapTimes.map(e => (
|
||||
<li key={"mapkey/" + e.mapname + "/" + e.mapstage} id={"playermaps/" + e.mapname + "/" + e.mapstage}>
|
||||
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', }}>
|
||||
<a href={"http://steamcommunity.com/profiles/" + this.state.player.steamID64}>
|
||||
<strong className="col-lg-1 col-centered" /> {this.state.player.steamID}<br />
|
||||
<strong className="col-lg-1 col-centered" />{this.state.player.name}<br />
|
||||
<img src={this.state.player.Avatar} alt="" /> <br />
|
||||
<strong className="col-lg-1 col-centered" />Rank: {this.state.player.Rank}<br />
|
||||
<strong className="col-lg-1 col-centered" />Points: {this.state.player.PlayerPoints}<br />
|
||||
<strong className="col-lg-1 col-centered" />Times: {this.state.player.Times}<br />
|
||||
{badges}
|
||||
</a>
|
||||
</div>
|
||||
<div className="container mm">
|
||||
<div className="row">
|
||||
{this.state.mapTimes.map(e => (
|
||||
<div className="item" key={"playermapkey/" + e.mapname + "/" + e.mapstage} id={"playermaps/" + e.mapname + "/" + e.mapstage}>
|
||||
<div className="box_grid">
|
||||
<NavLink to={'/map/' + e.mapname + "/" + e.mapstage}>
|
||||
<strong className="col-lg-1 col-centered" /> Map: {e.mapname}<br />
|
||||
<strong className="col-lg-1 col-centered" /> Stage: {e.mapstage}<br />
|
||||
@ -125,18 +130,16 @@ class Player extends React.Component {
|
||||
<br />
|
||||
<br />
|
||||
</NavLink>
|
||||
</li>
|
||||
))}
|
||||
{!this.state.breakload ? <h1>
|
||||
Loading Stats <br /> <br /> <LoadingIndicator />
|
||||
</h1> : ""}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{!this.state.breakload ? <h1>
|
||||
Loading Stats <br /> <br /> <LoadingIndicator />
|
||||
</h1> : ""}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default Player;
|
@ -2621,6 +2621,7 @@ video {
|
||||
animation: pop-in 9s .2s cubic-bezier(0, .8, 0, 4) forwards;
|
||||
background-color: #FFF;
|
||||
content: "";
|
||||
/* https://images.unsplash.com/photo-1459749411175-04bf5292ceea?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80*/
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@ -2628,7 +2629,7 @@ video {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
background-image: url('https://images.unsplash.com/photo-1459749411175-04bf5292ceea?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80');
|
||||
background-image: url('https://vignette.wikia.nocookie.net/zombieescape/images/9/98/Ze_predator_ultimate_v3_css.png/revision/latest?cb=20120105193018');
|
||||
}
|
||||
|
||||
.hero_single .wrapper h3 {
|
||||
|
@ -4,7 +4,6 @@ import { NavLink } from 'react-router-dom';
|
||||
class playersSearch extends Component {
|
||||
state = {
|
||||
players: [],
|
||||
searchBool: true,
|
||||
};
|
||||
|
||||
componentDidMount = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user