<commit_before>package com.houseofmoran.zeitgeist

import javax.servlet.http.{HttpServletRequest, HttpServletResponse}

import org.eclipse.jetty.server.Request
import org.eclipse.jetty.server.handler.AbstractHandler
import org.json4s.native.JsonMethods._

class TweetSampleHandler(sample: TweetSample) extends AbstractHandler {
   override def handle(target: String, baseRequest: Request,
                       request: HttpServletRequest, response: HttpServletResponse): Unit =
   {
     if (target == "/api/sample") {
       response.setContentType("application/json; charset=utf-8")
       response.setStatus(HttpServletResponse.SC_OK)
       response.getWriter().print(pretty(render(sample.toJSON())))

       baseRequest.setHandled(true);
     }
   }
 }<commit_msg>refactor: make TweetSampleHandler only depend on a structural type having toJSON()<commit_after>package com.houseofmoran.zeitgeist

import javax.servlet.http.{HttpServletRequest, HttpServletResponse}

import org.eclipse.jetty.server.Request
import org.eclipse.jetty.server.handler.AbstractHandler
import org.json4s.JValue
import org.json4s.native.JsonMethods._

class TweetSampleHandler(sample: { def toJSON() : JValue}) extends AbstractHandler {
   override def handle(target: String, baseRequest: Request,
                       request: HttpServletRequest, response: HttpServletResponse): Unit =
   {
     if (target == "/api/sample") {
       response.setContentType("application/json; charset=utf-8")
       response.setStatus(HttpServletResponse.SC_OK)
       response.getWriter().print(pretty(render(sample.toJSON())))

       baseRequest.setHandled(true);
     }
   }
 }
{'fraction_non_alphanumeric': 0.1055184960582171, 'fraction_numerical': 0.0030321406913280777, 'mean_word_length': 4.305466237942122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1463564', 'n_tokens_mistral': 463, 'n_tokens_neox': 458, 'n_words': 84}