Added too much functionality with redis + fix for build docker stage and added run stage
Some checks failed
Build and push image / deploy (push) Failing after 27s
Some checks failed
Build and push image / deploy (push) Failing after 27s
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
FROM eclipse-temurin:21-jdk-jammy
|
FROM maven:3.9.6-eclipse-temurin-21
|
||||||
|
|
||||||
# build
|
# build
|
||||||
WORKDIR app
|
WORKDIR app
|
||||||
COPY pom.xml .
|
COPY . .
|
||||||
RUN mvn -f /app/pom.xml clean package -Dmaven.test.skip=true
|
RUN mvn -f pom.xml clean package -Dmaven.test.skip=true
|
||||||
|
|
||||||
|
# run
|
||||||
|
RUN java -jar target/testSteamPrices .jar
|
2
pom.xml
2
pom.xml
@ -7,6 +7,7 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
||||||
<name>testSteamPrices</name>
|
<name>testSteamPrices</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
@ -62,5 +63,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<finalName>testSteamPrices</finalName>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
61
src/main/java/org/example/GameInfoMapper.java
Normal file
61
src/main/java/org/example/GameInfoMapper.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package org.example;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GameInfoMapper
|
||||||
|
{
|
||||||
|
public GameInfoResponse mapGameInfoJson(JsonNode node)
|
||||||
|
{
|
||||||
|
GameInfoResponse response = new GameInfoResponse();
|
||||||
|
response.setName(node.get("name").toString().replaceAll("\"", ""));
|
||||||
|
response.setPage_image(node.get("page_image").toString().replaceAll("\"", ""));
|
||||||
|
response.setSmall_logo(node.get("small_logo").toString().replaceAll("\"", ""));
|
||||||
|
|
||||||
|
if (node.get("apps").isArray())
|
||||||
|
{
|
||||||
|
ArrayList<GameInfoResponse.AppClass> apps = new ArrayList<>();
|
||||||
|
for (JsonNode jsonNode : node.get("apps"))
|
||||||
|
{
|
||||||
|
apps.add(new GameInfoResponse.AppClass(jsonNode.get("id").asInt(), jsonNode.get("name").toString().replaceAll("\"", "")));
|
||||||
|
}
|
||||||
|
response.setApps(apps);
|
||||||
|
}
|
||||||
|
GameInfoResponse.Price price = null;
|
||||||
|
if (node.get("price") != null)
|
||||||
|
{
|
||||||
|
price = new GameInfoResponse.Price(node.get("price").get("currency").toString().replaceAll("\"", ""), node.get("price").get("initial").asInt(), node.get("price").get("final").asInt(), node.get("price").get("discount_percent").asInt(), node.get("price").get("individual").asInt());
|
||||||
|
}
|
||||||
|
response.setPrice(price);
|
||||||
|
|
||||||
|
GameInfoResponse.Platforms platforms = new GameInfoResponse.Platforms(node.get("platforms").get("windows").asBoolean(), node.get("platforms").get("mac").asBoolean(), node.get("platforms").get("linux").asBoolean());
|
||||||
|
response.setPlatforms(platforms);
|
||||||
|
|
||||||
|
GameInfoResponse.Controller controller = new GameInfoResponse.Controller(node.get("controller").get("full_gamepad").asBoolean());
|
||||||
|
response.setController(controller);
|
||||||
|
|
||||||
|
GameInfoResponse.ReleaseDate releaseDate = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String jsonDate = node.get("release_date").get("date").toString().replaceAll("\"", "");
|
||||||
|
Date formattedDate = null;
|
||||||
|
if (!jsonDate.isEmpty())
|
||||||
|
{
|
||||||
|
formattedDate = new SimpleDateFormat("dd MMM, yyyy", Locale.ENGLISH).parse(jsonDate);
|
||||||
|
}
|
||||||
|
releaseDate = new GameInfoResponse.ReleaseDate(node.get("release_date").get("coming_soon").asBoolean(), formattedDate);
|
||||||
|
}
|
||||||
|
catch (ParseException e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
response.setRelease_date(releaseDate);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
@ -1,34 +1,267 @@
|
|||||||
package org.example;
|
package org.example;
|
||||||
|
|
||||||
import lombok.Getter;
|
import java.util.ArrayList;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
public class GameInfoResponse
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
|
||||||
final class GameInfoResponse
|
|
||||||
{
|
{
|
||||||
|
private String name;
|
||||||
|
|
||||||
private Map<String, String> data;
|
private String page_image;
|
||||||
private List<Map<String, String>> apps;
|
|
||||||
private Map<String, Float> price;
|
|
||||||
private Map<String, String> platforms;
|
|
||||||
private Map<String, String> controller;
|
|
||||||
private Map<String, ReleaseDate> date;
|
|
||||||
|
|
||||||
@Getter
|
private String small_logo;
|
||||||
@Setter
|
|
||||||
@NoArgsConstructor
|
private ArrayList<AppClass> apps;
|
||||||
private static final class ReleaseDate
|
|
||||||
|
private Price price;
|
||||||
|
|
||||||
|
private Platforms platforms;
|
||||||
|
|
||||||
|
private Controller controller;
|
||||||
|
|
||||||
|
private ReleaseDate release_date;
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPage_image()
|
||||||
|
{
|
||||||
|
return page_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage_image(String page_image)
|
||||||
|
{
|
||||||
|
this.page_image = page_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSmall_logo()
|
||||||
|
{
|
||||||
|
return small_logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSmall_logo(String small_logo)
|
||||||
|
{
|
||||||
|
this.small_logo = small_logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<AppClass> getApps()
|
||||||
|
{
|
||||||
|
return apps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApps(ArrayList<AppClass> apps)
|
||||||
|
{
|
||||||
|
this.apps = apps;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Price getPrice()
|
||||||
|
{
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(Price price)
|
||||||
|
{
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Platforms getPlatforms()
|
||||||
|
{
|
||||||
|
return platforms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlatforms(Platforms platforms)
|
||||||
|
{
|
||||||
|
this.platforms = platforms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Controller getController()
|
||||||
|
{
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setController(Controller controller)
|
||||||
|
{
|
||||||
|
this.controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReleaseDate getRelease_date()
|
||||||
|
{
|
||||||
|
return release_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRelease_date(ReleaseDate release_date)
|
||||||
|
{
|
||||||
|
this.release_date = release_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AppClass
|
||||||
|
{
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public AppClass()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppClass(int id, String name)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Price
|
||||||
|
{
|
||||||
|
private String currency;
|
||||||
|
|
||||||
|
private int initial;
|
||||||
|
|
||||||
|
private int finals;
|
||||||
|
|
||||||
|
private int discount_percent;
|
||||||
|
|
||||||
|
private int individual;
|
||||||
|
|
||||||
|
public Price()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Price(String currency, int initial, int finals, int discount_percent, int individual)
|
||||||
|
{
|
||||||
|
this.currency = currency;
|
||||||
|
this.initial = initial;
|
||||||
|
this.finals = finals;
|
||||||
|
this.discount_percent = discount_percent;
|
||||||
|
this.individual = individual;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrency()
|
||||||
|
{
|
||||||
|
return currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInitial()
|
||||||
|
{
|
||||||
|
return initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFinals()
|
||||||
|
{
|
||||||
|
return finals;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDiscount_percent()
|
||||||
|
{
|
||||||
|
return discount_percent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndividual()
|
||||||
|
{
|
||||||
|
return individual;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Platforms
|
||||||
|
{
|
||||||
|
private boolean windows;
|
||||||
|
|
||||||
|
private boolean mac;
|
||||||
|
|
||||||
|
private boolean linux;
|
||||||
|
|
||||||
|
public Platforms()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Platforms(boolean windows, boolean mac, boolean linux)
|
||||||
|
{
|
||||||
|
this.windows = windows;
|
||||||
|
this.mac = mac;
|
||||||
|
this.linux = linux;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWindows()
|
||||||
|
{
|
||||||
|
return windows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMac()
|
||||||
|
{
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLinux()
|
||||||
|
{
|
||||||
|
return linux;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Controller
|
||||||
|
{
|
||||||
|
private boolean full_gamepad;
|
||||||
|
|
||||||
|
|
||||||
|
public Controller()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Controller(boolean full_gamepad)
|
||||||
|
{
|
||||||
|
this.full_gamepad = full_gamepad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFull_gamepad()
|
||||||
|
{
|
||||||
|
return full_gamepad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ReleaseDate
|
||||||
{
|
{
|
||||||
private boolean coming_soon;
|
private boolean coming_soon;
|
||||||
|
|
||||||
private Date date;
|
private Date date;
|
||||||
|
|
||||||
|
public ReleaseDate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReleaseDate(boolean coming_soon, Date date)
|
||||||
|
{
|
||||||
|
this.coming_soon = coming_soon;
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isComing_soon()
|
||||||
|
{
|
||||||
|
return coming_soon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate()
|
||||||
|
{
|
||||||
|
return date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.example;
|
package org.example;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import redis.clients.jedis.HostAndPort;
|
import redis.clients.jedis.HostAndPort;
|
||||||
@ -15,6 +16,9 @@ public class LoadGameService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GameInfoMapper mapper;
|
||||||
|
|
||||||
|
|
||||||
public void loadGamesbySingleThread() throws InterruptedException
|
public void loadGamesbySingleThread() throws InterruptedException
|
||||||
{
|
{
|
||||||
@ -35,17 +39,26 @@ public class LoadGameService
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (e.getMessage().equals("429"))
|
if (e.getMessage().equals("429"))
|
||||||
{
|
{
|
||||||
Thread.sleep(30000);
|
Thread.sleep(240000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
//TODO: add filter for successful and unsuccessful requests
|
if (json.get(Integer.toString(i)).get("success").asBoolean())
|
||||||
jedis.set(String.valueOf(i), json.toString());
|
{
|
||||||
System.out.println("Current id = " + i);
|
GameInfoResponse infoResponse = mapper.mapGameInfoJson(json.get(Integer.toString(i)).get("data"));
|
||||||
System.out.println(json.toPrettyString());
|
jedis.set(infoResponse.getName(), new ObjectMapper().writeValueAsString(infoResponse));
|
||||||
|
System.out.println("Current id = " + i);
|
||||||
|
System.out.println(json.toPrettyString());
|
||||||
|
GameInfoResponse newResponse = new ObjectMapper().readValue(jedis.get(infoResponse.getName()), GameInfoResponse.class);
|
||||||
|
System.out.println("Value loaded from Redis = " + jedis.get(json.get(Integer.toString(i)).get("data").get("name").toString()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("Game with id = " + i + " does not exist in Steam");
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@ public class SteamConstants
|
|||||||
final static String GAME_DETAILS_API_TEMPLATE = "https://store.steampowered.com/api/packagedetails?packageids=%s&cc=%s&filters=price_overview";
|
final static String GAME_DETAILS_API_TEMPLATE = "https://store.steampowered.com/api/packagedetails?packageids=%s&cc=%s&filters=price_overview";
|
||||||
final static String REDIS_HOST = "rc1a-67kduigjscq90cna.mdb.yandexcloud.net";
|
final static String REDIS_HOST = "rc1a-67kduigjscq90cna.mdb.yandexcloud.net";
|
||||||
final static String REDIS_PASS = "Q1598520q";
|
final static String REDIS_PASS = "Q1598520q";
|
||||||
final static String PROXY_HOST = "91.147.123.214";
|
final static String PROXY_HOST = "77.73.134.212";
|
||||||
final static int PROXY_PORT = 50101;
|
final static int PROXY_PORT = 8000;
|
||||||
final static String PROXY_USER = "pavel0RG3T";
|
final static String PROXY_USER = "KzMUMc";
|
||||||
final static String PROXY_PASS = "pJ9KTE9QbD";
|
final static String PROXY_PASS = "457pZN";
|
||||||
final static String CA_CERT_PASS = "Q1598520q";
|
final static String CA_CERT_PASS = "Q1598520q";
|
||||||
final static String USER_CERT_PASS = "Q1598520q";
|
final static String USER_CERT_PASS = "Q1598520q";
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
package org.example;
|
package org.example;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
public class SteamPriceParser
|
public class SteamPriceParser
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public static Map<Integer, Boolean> gameCodeList = new HashMap<>();
|
public static Map<Integer, Boolean> gameCodeList = new HashMap<>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
Reference in New Issue
Block a user