<commit_before>package com.azavea.rf.database.notification.templates

import com.azavea.rf.database._
import com.azavea.rf.datamodel._

import cats.implicits._
import doobie.ConnectionIO
import doobie.implicits._

import java.util.UUID

case class UploadSuccess(
  uploadId: UUID,
  platformId: UUID
) {
  def build: ConnectionIO[EmailData] = {
    for {
      platform <- PlatformDao.unsafeGetPlatformById(platformId)
      platformHost = platform.publicSettings.platformHost.getOrElse("app.rasterfoundry.com")
      upload <- UploadDao.unsafeGetUploadById(uploadId)
      owner <- UserDao.unsafeGetUserById(upload.owner)
      uploadProject <- upload.projectId match {
        case Some(id) => ProjectDao.getProjectById(id, Some(owner))
        case _ => None.pure[ConnectionIO]
      }
    } yield {
      val signature = s"- The ${platform.name} Team"
      val importsUrl = s"https://${platformHost}/imports/rasters?page=1"
      val sceneAddedMsg = "A scene has successfully been added to your project"
      val statusMsg = "You can check the status of all of your processing scenes any time"
      val withImportIDMsg = s"with Import ID ${upload.id}"
      val newSceneMsg = "A new scene has been added to your project"

      uploadProject.map(project => {
        val projectUrl = s"https://${platformHost}/projects/${project.id}"
        val subject = s"""${newSceneMsg} "${project.name}""""
        val plainBody = s"""
          | ${sceneAddedMsg} at ${projectUrl} ${withImportIDMsg}. ${statusMsg} at: ${importsUrl}.
          |
          | ${signature}
          """.trim.stripMargin
        val richBody = s"""
<html>
  <p>
    ${sceneAddedMsg} <a href="${projectUrl}">${project.name}</a> ${withImportIDMsg}. ${statusMsg} on the <a href="${importsUrl}">Imports Page</a>.
  </p>
  <p>
    ${signature}
  </p>
</html>""".trim.stripMargin<commit_msg>Fix path to project in success email<commit_after>package com.azavea.rf.database.notification.templates

import com.azavea.rf.database._
import com.azavea.rf.datamodel._

import cats.implicits._
import doobie.ConnectionIO
import doobie.implicits._

import java.util.UUID

case class UploadSuccess(
  uploadId: UUID,
  platformId: UUID
) {
  def build: ConnectionIO[EmailData] = {
    for {
      platform <- PlatformDao.unsafeGetPlatformById(platformId)
      platformHost = platform.publicSettings.platformHost.getOrElse("app.rasterfoundry.com")
      upload <- UploadDao.unsafeGetUploadById(uploadId)
      owner <- UserDao.unsafeGetUserById(upload.owner)
      uploadProject <- upload.projectId match {
        case Some(id) => ProjectDao.getProjectById(id, Some(owner))
        case _ => None.pure[ConnectionIO]
      }
    } yield {
      val signature = s"- The ${platform.name} Team"
      val importsUrl = s"https://${platformHost}/imports/rasters?page=1"
      val sceneAddedMsg = "A scene has successfully been added to your project"
      val statusMsg = "You can check the status of all of your processing scenes any time"
      val withImportIDMsg = s"with Import ID ${upload.id}"
      val newSceneMsg = "A new scene has been added to your project"

      uploadProject.map(project => {
        val projectUrl = s"https://${platformHost}/projects/edit/${project.id}"
        val subject = s"""${newSceneMsg} "${project.name}""""
        val plainBody = s"""
          | ${sceneAddedMsg} at ${projectUrl} ${withImportIDMsg}. ${statusMsg} at: ${importsUrl}.
          |
          | ${signature}
          """.trim.stripMargin
        val richBody = s"""
<html>
  <p>
    ${sceneAddedMsg} <a href="${projectUrl}">${project.name}</a> ${withImportIDMsg}. ${statusMsg} on the <a href="${importsUrl}">Imports Page</a>.
  </p>
  <p>
    ${signature}
  </p>
</html>""".trim.stripMargin
{'fraction_non_alphanumeric': 0.13512793176972282, 'fraction_numerical': 0.0005330490405117271, 'mean_word_length': 3.3137931034482757, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, 'https://': 4, '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': '5222259', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1156, 'n_words': 275}