From 867fc5801186df59588b57f8a2bd9dd86223a1f8 Mon Sep 17 00:00:00 2001 From: Mister-Mario Date: Thu, 25 Apr 2024 19:49:53 +0200 Subject: [PATCH] Removed transaction idea --- questionGenerator/src/main/java/Main.java | 16 ++++++++-------- .../repository/QuestionRepository.java | 9 +-------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/questionGenerator/src/main/java/Main.java b/questionGenerator/src/main/java/Main.java index a810d5ba..e5c144aa 100644 --- a/questionGenerator/src/main/java/Main.java +++ b/questionGenerator/src/main/java/Main.java @@ -12,21 +12,21 @@ public class Main { private static QuestionGenerator qg = QuestionGenerator.getInstance(); - // private static final long TIME_SKIP = 18000000; //5 hours + private static final long TIME_SKIP = 18000000; //5 hours // private static final long TIME_SKIP = 43200000; //12 hours - private static final long TIME_SKIP = 1000; //1 minute + //private static final long TIME_SKIP = 1000; //1 minute private static String[] languages = {"en", "es", "tr"}; private static QuestionType[] types = {QuestionType.CAPITAL, QuestionType.LANGUAGE, QuestionType.POPULATION, - QuestionType.SIZE, QuestionType.HEAD_OF_GOVERMENT, QuestionType.VIDEOGAME_DEVELOPER, - QuestionType.VIDEOGAME_PUBLISHER, QuestionType.VIDEOGAME_GENRE, QuestionType.VIDEOGAME_COUNTRY}; + QuestionType.SIZE, QuestionType.HEAD_OF_GOVERMENT}; + //, QuestionType.VIDEOGAME_DEVELOPER, QuestionType.VIDEOGAME_PUBLISHER, QuestionType.VIDEOGAME_GENRE, QuestionType.VIDEOGAME_COUNTRY}; - // private static final int NUMBER_OF_QUESTIONS = 50; - // private static final int NUMBER_OF_QUESTIONS = 100; - // private static final int NUMBER_OF_QUESTIONS = 3; - private static final int NUMBER_OF_QUESTIONS = 1; + //private static final int NUMBER_OF_QUESTIONS = 50; + private static final int NUMBER_OF_QUESTIONS = 100; + //private static final int NUMBER_OF_QUESTIONS = 3; + //private static final int NUMBER_OF_QUESTIONS = 1; public static void main(String[] args) { while(true) { diff --git a/questionGenerator/src/main/java/questionGenerator/repository/QuestionRepository.java b/questionGenerator/src/main/java/questionGenerator/repository/QuestionRepository.java index bc6546c7..d79636d0 100644 --- a/questionGenerator/src/main/java/questionGenerator/repository/QuestionRepository.java +++ b/questionGenerator/src/main/java/questionGenerator/repository/QuestionRepository.java @@ -1,6 +1,5 @@ package main.java.questionGenerator.repository; -import com.mongodb.client.ClientSession; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; import com.mongodb.client.MongoCollection; @@ -81,9 +80,6 @@ public boolean populate(List questions) { try (MongoClient mongoClient = MongoClients.create(dbConnectionString)) { MongoDatabase database = mongoClient.getDatabase("questions"); - ClientSession session = mongoClient.startSession(); - session.startTransaction(); - MongoCollection collection = database.getCollection("questions"); collection.deleteMany(Document.parse("{}")); @@ -93,10 +89,7 @@ public boolean populate(List questions) { documents.add(Document.parse(questionJSON)); } - collection.insertMany(session, documents); - - session.commitTransaction(); - session.close(); + collection.insertMany(documents); return true;