Skip to content

Commit

Permalink
Removed transaction idea
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Mario committed Apr 25, 2024
1 parent 30f56e9 commit 867fc58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
16 changes: 8 additions & 8 deletions questionGenerator/src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -81,9 +80,6 @@ public boolean populate(List<String> questions) {
try (MongoClient mongoClient = MongoClients.create(dbConnectionString)) {
MongoDatabase database = mongoClient.getDatabase("questions");

ClientSession session = mongoClient.startSession();
session.startTransaction();

MongoCollection<Document> collection = database.getCollection("questions");

collection.deleteMany(Document.parse("{}"));
Expand All @@ -93,10 +89,7 @@ public boolean populate(List<String> questions) {
documents.add(Document.parse(questionJSON));
}

collection.insertMany(session, documents);

session.commitTransaction();
session.close();
collection.insertMany(documents);

return true;

Expand Down

0 comments on commit 867fc58

Please sign in to comment.