<commit_before>package drt.staff

import org.joda.time.{DateTime, DateTimeZone}
import play.api.libs.json.{JsResult, JsValue, Json, Reads}
import services.SDate
import services.SDate.implicits._

import scala.util.parsing.json.JSON

case class StaffShift(port_code: String, terminal: String, staff: String, shift_start: String)

case class StaffShifts(shifts: List[StaffShift])

object ImportStaff {
  def staffJsonToShifts(staffJson: JsValue): Option[String] = {
    implicit val shiftFormat = Json.format[StaffShift]
    implicit val shiftsFormat = Json.format[StaffShifts]
    staffJson.validate[StaffShifts].asOpt map {
      case StaffShifts(shifts) =>
        shifts.zipWithIndex.map{
          case (shift, index) =>
            //The client deals in local time, and these shifts are sent to the client as strings with no timezone for now.
            //TODO: store shifts not as strings.
            val shiftStartDate = new DateTime(shift.shift_start).withZone(DateTimeZone.forID("Europe/London"))
            val shiftsEndDate = shiftStartDate.addMinutes(15)

            f"shift$index, ${shift.terminal}, ${shiftStartDate.ddMMyyString}, ${shiftStartDate.getHours()}%02d:${shiftStartDate.getMinutes()}%02d, ${shiftsEndDate.getHours()}%02d:${shiftsEndDate.getMinutes()}%02d, ${shift.staff}"
        }.mkString("\n")
    }
  }
}<commit_msg>DRT-4639 Correct imported shifts to be 15 minutes rather than 16<commit_after>package drt.staff

import org.joda.time.{DateTime, DateTimeZone}
import play.api.libs.json.{JsResult, JsValue, Json, Reads}
import services.SDate
import services.SDate.implicits._

import scala.util.parsing.json.JSON

case class StaffShift(port_code: String, terminal: String, staff: String, shift_start: String)

case class StaffShifts(shifts: List[StaffShift])

object ImportStaff {
  def staffJsonToShifts(staffJson: JsValue): Option[String] = {
    implicit val shiftFormat = Json.format[StaffShift]
    implicit val shiftsFormat = Json.format[StaffShifts]
    staffJson.validate[StaffShifts].asOpt map {
      case StaffShifts(shifts) =>
        shifts.zipWithIndex.map{
          case (shift, index) =>
            //The client deals in local time, and these shifts are sent to the client as strings with no timezone for now.
            //TODO: store shifts not as strings.
            val shiftStartDate = new DateTime(shift.shift_start).withZone(DateTimeZone.forID("Europe/London"))
            val shiftsEndDate = shiftStartDate.addMinutes(14)

            f"shift$index, ${shift.terminal}, ${shiftStartDate.ddMMyyString}, ${shiftStartDate.getHours()}%02d:${shiftStartDate.getMinutes()}%02d, ${shiftsEndDate.getHours()}%02d:${shiftsEndDate.getMinutes()}%02d, ${shift.staff}"
        }.mkString("\n")
    }
  }
}
{'fraction_non_alphanumeric': 0.11685475063705861, 'fraction_numerical': 0.010192937750273025, 'mean_word_length': 4.070110701107011, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2268003', 'n_tokens_mistral': 872, 'n_tokens_neox': 833, 'n_words': 196}