<commit_before>package com.commafeed.frontend.servlet;

import java.io.IOException;

import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.RequiredArgsConstructor;

import org.hibernate.SessionFactory;

import com.commafeed.backend.dao.UnitOfWork;
import com.commafeed.backend.dao.UserSettingsDAO;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserSettings;
import com.commafeed.backend.service.UserService;
import com.commafeed.frontend.SessionHelper;
import com.google.common.base.Optional;

@SuppressWarnings("serial")
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class CustomCssServlet extends HttpServlet {

	private final SessionFactory sessionFactory;
	private final UserSettingsDAO userSettingsDAO;
	private final UserService userService;

	@Override
	protected void doGet(final HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/css");

		final Optional<User> user = new UnitOfWork<Optional<User>>(sessionFactory) {
			@Override
			protected Optional<User> runInSession() throws Exception {
				SessionHelper sessionHelper = new SessionHelper(req);
				Optional<User> loggedInUser = sessionHelper.getLoggedInUser();
				if (loggedInUser.isPresent()) {
					userService.performPostLoginActivities(loggedInUser.get());
				}
				return loggedInUser;
			}
		}.run();
		if (!user.isPresent()) {
			return;
		}

		UserSettings settings = new UnitOfWork<UserSettings>(sessionFactory) {
			@Override
			protected UserSettings runInSession() {
				return userSettingsDAO.findByUser(user.get());
			}
		}.run();

		if (settings == null || settings.getCustomCss() == null) {
			return;
		}

		resp.getWriter().write(settings.getCustomCss());
	}
}
<commit_msg>performing post login activities for the custom css is not needed since the css is only retrieved on the website and api methods are going to get called right after this<commit_after>package com.commafeed.frontend.servlet;

import java.io.IOException;

import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.RequiredArgsConstructor;

import org.hibernate.SessionFactory;

import com.commafeed.backend.dao.UnitOfWork;
import com.commafeed.backend.dao.UserSettingsDAO;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserSettings;
import com.commafeed.frontend.SessionHelper;
import com.google.common.base.Optional;

@SuppressWarnings("serial")
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class CustomCssServlet extends HttpServlet {

	private final SessionFactory sessionFactory;
	private final UserSettingsDAO userSettingsDAO;

	@Override
	protected void doGet(final HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/css");

		final Optional<User> user = new UnitOfWork<Optional<User>>(sessionFactory) {
			@Override
			protected Optional<User> runInSession() throws Exception {
				return new SessionHelper(req).getLoggedInUser();
			}
		}.run();
		if (!user.isPresent()) {
			return;
		}

		UserSettings settings = new UnitOfWork<UserSettings>(sessionFactory) {
			@Override
			protected UserSettings runInSession() {
				return userSettingsDAO.findByUser(user.get());
			}
		}.run();

		if (settings == null || settings.getCustomCss() == null) {
			return;
		}

		resp.getWriter().write(settings.getCustomCss());
	}
}

{'fraction_non_alphanumeric': 0.09951764407209952, 'fraction_numerical': 0.0, 'mean_word_length': 4.677233429394812, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '1463518', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1131, 'n_words': 239}