use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class ScannerSerializer method main.
public static void main(String[] args) throws IOException, GeneralSecurityException {
GoogleSpreadSheetFactory.initWithFileSecret("client_secret.json");
GoogleSpreadSheetFactory.setSpreadsheetId(args[1]);
Sheets sheets = GoogleSpreadSheetFactory.getSheets();
List<List<Object>> results = sheets.spreadsheets().values().get(GoogleSpreadSheetFactory.getSpreadsheetID(), "Scanner Data!A:M").execute().getValues();
MongoConnection mongoConnection = new MongoConnection(args[0], "repairnator");
if (!mongoConnection.isConnected()) {
throw new RuntimeException("Error when connection to mongodb");
}
MongoDBSerializerEngine serializerEngine = new MongoDBSerializerEngine(mongoConnection);
List<SerializedData> data = new ArrayList<>();
for (int i = 1; i < results.size(); i++) {
List<Object> value = results.get(i);
JsonObject result = new JsonObject();
result.addProperty("hostname", Utils.getValue(value, 0));
result.addProperty("dateBegin", Utils.getValue(value, 1));
result.addProperty("dateLimit", Utils.getValue(value, 2));
result.addProperty("totalRepoNumber", Utils.getValue(value, 3));
result.addProperty("totalRepoUsingTravis", Utils.getValue(value, 4));
result.addProperty("totalScannedBuilds", Utils.getValue(value, 5));
result.addProperty("totalJavaBuilds", Utils.getValue(value, 6));
result.addProperty("totalJavaPassingBuilds", Utils.getValue(value, 7));
result.addProperty("totalJavaFailingBuilds", Utils.getValue(value, 8));
result.addProperty("totalJavaFailingBuildsWithFailingTests", Utils.getValue(value, 9));
result.addProperty("totalPRBuilds", Utils.getValue(value, 10));
result.addProperty("dayLimit", Utils.getValue(value, 11));
result.addProperty("duration", Utils.getValue(value, 12));
result.addProperty("runId", Utils.getValue(value, 13));
data.add(new SerializedData(Collections.EMPTY_LIST, result));
}
serializerEngine.serialize(data, SerializerType.SCANNER);
}
use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class ScannerSerializer4Bears method main.
public static void main(String[] args) throws IOException, GeneralSecurityException {
GoogleSpreadSheetFactory.initWithFileSecret("client_secret.json");
GoogleSpreadSheetFactory.setSpreadsheetId(args[1]);
Sheets sheets = GoogleSpreadSheetFactory.getSheets();
List<List<Object>> results = sheets.spreadsheets().values().get(GoogleSpreadSheetFactory.getSpreadsheetID(), "Scanner Data!A:M").execute().getValues();
MongoConnection mongoConnection = new MongoConnection(args[0], "bears");
if (!mongoConnection.isConnected()) {
throw new RuntimeException("Error when connection to mongodb");
}
MongoDBSerializerEngine serializerEngine = new MongoDBSerializerEngine(mongoConnection);
List<SerializedData> data = new ArrayList<>();
for (int i = 1; i < results.size(); i++) {
List<Object> value = results.get(i);
JsonObject result = new JsonObject();
result.addProperty("hostname", Utils.getValue(value, 0));
result.addProperty("dateBegin", Utils.getValue(value, 1));
result.addProperty("dateEnd", Utils.getValue(value, 2));
result.addProperty("duration", Utils.getValue(value, 3));
result.addProperty("dateLookedFrom", Utils.getValue(value, 4));
result.addProperty("dateLookedTo", Utils.getValue(value, 5));
result.addProperty("totalRepoNumber", Utils.getValue(value, 6));
result.addProperty("totalRepoUsingTravis", Utils.getValue(value, 7));
result.addProperty("totalScannedBuilds", Utils.getValue(value, 8));
result.addProperty("totalJavaBuilds", Utils.getValue(value, 9));
result.addProperty("totalJavaPassingBuilds", Utils.getValue(value, 10));
result.addProperty("totalJavaFailingBuilds", Utils.getValue(value, 11));
result.addProperty("totalJavaFailingBuildsWithFailingTests", Utils.getValue(value, 12));
result.addProperty("totalPRBuilds", Utils.getValue(value, 13));
result.addProperty("totalFailingAndPassingBuildPairs", Utils.getValue(value, 14));
result.addProperty("totalPassingAndPassingBuildPairs", Utils.getValue(value, 15));
result.addProperty("totalPairOfBuilds", Utils.getValue(value, 16));
result.addProperty("runId", Utils.getValue(value, 17));
data.add(new SerializedData(Collections.EMPTY_LIST, result));
}
serializerEngine.serialize(data, SerializerType.SCANNER4BEARS);
}
use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class CheckIfFutureBuildIdWhereWellComputed method main.
public static void main(String[] args) throws IOException {
List<String> allIds = Files.readAllLines(new File(args[0]).toPath());
String dbCollectionUrl = args[1];
String dbName = args[2];
String collectionName = args[3];
final List<String> projectsNames = Files.readAllLines(new File(args[4]).toPath());
String githubLogin = args[5];
String githubToken = args[6];
RepairnatorConfig.getInstance().setGithubLogin(githubLogin);
RepairnatorConfig.getInstance().setGithubToken(githubToken);
MongoConnection mongoConnection = new MongoConnection(dbCollectionUrl, dbName);
MongoDatabase database = mongoConnection.getMongoDatabase();
MongoCollection collection = database.getCollection(collectionName);
Calendar limitDateMay = Calendar.getInstance();
limitDateMay.set(2017, Calendar.MAY, 10);
HashMap<String, List<Integer>> results = new HashMap<>();
Block<Document> block = new Block<Document>() {
@Override
public void apply(Document document) {
Object pBuildId = document.get("previousBuildId");
if (pBuildId instanceof Integer) {
int previousBuildId = document.getInteger("previousBuildId", -1);
int nextBuildId = document.getInteger("buildId", -1);
if (previousBuildId != -1 && nextBuildId != -1) {
Build previousBuild = BuildHelper.getBuildFromId(previousBuildId, null);
Build nextBuild = BuildHelper.getNextBuildOfSameBranchOfStatusAfterBuild(previousBuild, null);
if (nextBuild.getId() != nextBuildId) {
String projectName = previousBuild.getRepository().getSlug();
if (projectsNames == null || projectsNames.contains(projectName)) {
if (!results.containsKey(projectName)) {
results.put(projectName, new ArrayList<>());
}
results.get(projectName).add(previousBuildId);
i++;
}
}
}
}
}
};
for (String s : allIds) {
int buildId = Integer.parseInt(s);
collection.find(and(gt("buildReproductionDate", limitDateMay.getTime()), eq("previousBuildId", buildId), eq("lastReproducedBuggyBuild", true))).forEach(block);
}
System.out.println(allIds.size() + " ids read, and got: " + i);
System.out.println(results.keySet().size() + " detected projects: (" + StringUtils.join(results.keySet(), ",") + ")");
System.out.println("Results:");
for (String s : results.keySet()) {
System.out.println("Project " + s + " : ");
System.out.println(StringUtils.join(results.get(s), "\n"));
System.out.println("\n");
}
}
use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class CheckIfIdsAreInDatabase method main.
public static void main(String[] args) throws IOException {
List<String> allIds = Files.readAllLines(new File(args[0]).toPath());
String dbCollectionUrl = args[1];
String dbName = args[2];
String collectionName = args[3];
List<String> projectsNames = null;
if (args.length > 4) {
projectsNames = Files.readAllLines(new File(args[4]).toPath());
String githubLogin = args[5];
String githubToken = args[6];
RepairnatorConfig.getInstance().setGithubLogin(githubLogin);
RepairnatorConfig.getInstance().setGithubToken(githubToken);
}
MongoConnection mongoConnection = new MongoConnection(dbCollectionUrl, dbName);
MongoDatabase database = mongoConnection.getMongoDatabase();
MongoCollection collection = database.getCollection(collectionName);
Calendar limitDateMay = Calendar.getInstance();
// limitDateMay.set(2017, Calendar.MAY, 10);
limitDateMay.set(2017, Calendar.SEPTEMBER, 8);
Calendar limitDateNow = Calendar.getInstance();
HashMap<String, List<Integer>> results = new HashMap<>();
int i = 0;
for (String s : allIds) {
int buildId = Integer.parseInt(s);
long total = collection.count(and(gt("buildReproductionDate", limitDateMay.getTime()), eq("previousBuildId", buildId)));
if (total == 0) {
Build build = BuildHelper.getBuildFromId(buildId, null);
String projectName = build.getRepository().getSlug();
if (projectsNames == null || projectsNames.contains(projectName)) {
if (!results.containsKey(projectName)) {
results.put(projectName, new ArrayList<>());
}
results.get(projectName).add(buildId);
i++;
}
}
}
System.out.println(allIds.size() + " ids read, and got: " + i);
System.out.println(results.keySet().size() + " detected projects: (" + StringUtils.join(results.keySet(), ",") + ")");
System.out.println("Results:");
for (String s : results.keySet()) {
System.out.println("Project " + s + " : ");
System.out.println(StringUtils.join(results.get(s), "\n"));
System.out.println("\n");
}
}
use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class UpdateDataForSpecifyingLastReproduction method main.
public static void main(String[] args) {
String dbConnectionUrl = args[0];
String dbName = args[1];
String collectionName = args[2];
MongoConnection mongoConnection = new MongoConnection(dbConnectionUrl, dbName);
MongoDatabase database = mongoConnection.getMongoDatabase();
MongoCollection collection = database.getCollection(collectionName);
Calendar limitDateMay = Calendar.getInstance();
limitDateMay.set(2017, Calendar.MAY, 10);
final List<ObjectId> updatedDocs = new ArrayList<>();
Set<Integer> ids = new HashSet<>();
Block<Document> block = new Block<Document>() {
@Override
public void apply(Document document) {
ObjectId documentId = document.getObjectId("_id");
Object pBuildId = document.get("previousBuildId");
if (pBuildId instanceof Integer) {
int previousBuildId = document.getInteger("previousBuildId", -1);
if (previousBuildId != -1) {
boolean lastReproducedBuggyBuild = !ids.contains(previousBuildId);
ids.add(previousBuildId);
document.append("lastReproducedBuggyBuild", lastReproducedBuggyBuild);
collection.replaceOne(eq("_id", documentId), document, new UpdateOptions().upsert(true));
updatedDocs.add(documentId);
}
}
}
};
collection.find().sort(orderBy(descending("buildReproductionDate"))).forEach(block);
System.out.println("Updated docs: " + updatedDocs.size());
}
Aggregations