<commit_before>package quizme;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import quizme.database.*;
import quizme.links.WebsiteStats;

/**
 * Servlet implementation class AdminServlet
 */
@WebServlet("/AdminServlet")
public class AdminServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public AdminServlet() {
		super();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UsersTable usersTable = (UsersTable) request.getServletContext().getAttribute("usersTable");
		int numOfUsers = usersTable.numOfUsers();
		
		FriendTable friendTable = (FriendTable) request.getServletContext().getAttribute("friendTable");
		int numOfFriendRelationships = friendTable.numOfFriendRelationships();
		
		QuizTable quizTable = (QuizTable) request.getServletContext().getAttribute("quizTable");
		int[] numOfQuizzesCreated = quizTable.numOfQuizzesCreated();
		
		QuizResultsTable resultsTable = (QuizResultsTable) request.getServletContext().getAttribute("resultsTable");
		int[] numOfQuizzesTaken = resultsTable.numOfQuizzesTaken();
		
		AchievementsTable achievementsTable = (AchievementsTable) request.getServletContext().getAttribute("achievementsTable");
		int[] numOfAchievements = achievementsTable.numOfAchievements();
		
		MessagesTable messagesTable = (MessagesTable) request.getServletContext().getAttribute("messagesTable");
		int[] numOfMessages = messagesTable.numOfMessages();
		
		WebsiteStats websiteStats = new WebsiteStats(numOfUsers, numOfFriendRelationships, numOfQuizzesCreated, 
													numOfQuizzesTaken, numOfAchievements, numOfMessages);
		request.setAttribute("WebsiteStats", websiteStats);
		request.getRequestDispatcher("admin.jsp").forward(request, response);
	}
}
<commit_msg>Added user and quiz data<commit_after>package quizme;

import java.io.IOException;
import java.sql.Timestamp;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import quizme.database.*;
import quizme.links.*;

/**
 * Servlet implementation class AdminServlet
 */
@WebServlet("/AdminServlet")
public class AdminServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final Timestamp fromTime = new Timestamp(1970, 1, 1, 0, 0, 0, 0);
	private static final int limit = 10000;  
	
	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public AdminServlet() {
		super();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		/* Data to show directly on the admin page */
		AnnouncementsTable announcementsTable = (AnnouncementsTable) request.getServletContext().getAttribute("announcementsTable");
		List<AnnouncementLink> announcements = announcementsTable.getAllAnnouncementsList();
		request.setAttribute("announcements", announcements);
		
		UsersTable usersTable = (UsersTable) request.getServletContext().getAttribute("usersTable");
		List<User> users = usersTable.usersList();
		request.setAttribute("users", users);
		
		QuizTable quizTable = (QuizTable) request.getServletContext().getAttribute("quizTable");
		List<QuizLink> quizzes = quizTable.getRecentQuizzesCreated(limit, fromTime);
		request.setAttribute("quizzes", quizzes);
		
		/* Data for the website statistics */
		int numOfUsers = usersTable.numOfUsers();
		
		FriendTable friendTable = (FriendTable) request.getServletContext().getAttribute("friendTable");
		int numOfFriendRelationships = friendTable.numOfFriendRelationships();
		
		
		int[] numOfQuizzesCreated = quizTable.numOfQuizzesCreated();
		
		QuizResultsTable resultsTable = (QuizResultsTable) request.getServletContext().getAttribute("resultsTable");
		int[] numOfQuizzesTaken = resultsTable.numOfQuizzesTaken();
		
		AchievementsTable achievementsTable = (AchievementsTable) request.getServletContext().getAttribute("achievementsTable");
		int[] numOfAchievements = achievementsTable.numOfAchievements();
		
		MessagesTable messagesTable = (MessagesTable) request.getServletContext().getAttribute("messagesTable");
		int[] numOfMessages = messagesTable.numOfMessages();
		
		WebsiteStats websiteStats = new WebsiteStats(numOfUsers, numOfFriendRelationships, numOfQuizzesCreated, 
													numOfQuizzesTaken, numOfAchievements, numOfMessages);
		request.setAttribute("websiteStats", websiteStats);
		request.getRequestDispatcher("admin.jsp").forward(request, response);
	}
}

{'fraction_non_alphanumeric': 0.10180505415162455, 'fraction_numerical': 0.0030685920577617327, 'mean_word_length': 6.528532608695652, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7632332', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1467, 'n_words': 308}