<commit_before>package nl.malienkolders.htm.admin.snippet
import net.liftweb._
import http._
import util.Helpers._
import scala.xml.NodeSeq
import nl.malienkolders.htm.lib.model._
import nl.malienkolders.htm.admin.lib.ParticipantImporter
import net.liftweb.common.Full
import net.liftweb.http.js.JsCmd
import net.liftweb.common.Box
import net.liftweb.common.Empty
import net.liftweb.common.Loggable
import nl.malienkolders.htm.admin.lib.PhotoImporterBackend
import java.io.FileOutputStream

object PhotoImporter extends Loggable {

  def render = {
    var upload: Box[FileParamHolder] = Empty

    def processForm() = upload match {
      case Full(FileParamHolder(_, mime, fileName, file)) if mime.startsWith("application/") =>
        val participantIds = Participant.findAll.map(_.externalId.get).toList

        PhotoImporterBackend.doImport(file, participantIds.toIterator)
        S.notice("Imported " + fileName)

      case Full(FileParamHolder(_, mime, _, _)) => S.notice("Invalid mime-type: " + mime)
      case _ => S.notice("No file?")
    }

    "#file" #> SHtml.fileUpload(f => upload = Full(f)) &
      "type=submit" #> SHtml.onSubmitUnit(processForm)
  }

}<commit_msg>bugfix photoimporter: participants where not ordered by externalId<commit_after>package nl.malienkolders.htm.admin.snippet
import net.liftweb._
import http._
import util.Helpers._
import scala.xml.NodeSeq
import nl.malienkolders.htm.lib.model._
import nl.malienkolders.htm.admin.lib.ParticipantImporter
import net.liftweb.common.Full
import net.liftweb.http.js.JsCmd
import net.liftweb.common.Box
import net.liftweb.common.Empty
import net.liftweb.common.Loggable
import nl.malienkolders.htm.admin.lib.PhotoImporterBackend
import java.io.FileOutputStream

object PhotoImporter extends Loggable {

  def render = {
    var upload: Box[FileParamHolder] = Empty

    def processForm() = upload match {
      case Full(FileParamHolder(_, mime, fileName, file)) if mime.startsWith("application/") =>
        val participantIds = Participant.findAll.sortBy(_.externalId.get.toInt).map(_.externalId.get).toList

        PhotoImporterBackend.doImport(file, participantIds.toIterator)
        S.notice("Imported " + fileName)

      case Full(FileParamHolder(_, mime, _, _)) => S.notice("Invalid mime-type: " + mime)
      case _ => S.notice("No file?")
    }

    "#file" #> SHtml.fileUpload(f => upload = Full(f)) &
      "type=submit" #> SHtml.onSubmitUnit(processForm)
  }

}
{'fraction_non_alphanumeric': 0.11848534201954397, 'fraction_numerical': 0.0, 'mean_word_length': 4.227659574468085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3959704', 'n_tokens_mistral': 825, 'n_tokens_neox': 811, 'n_words': 149}