Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEP #1548

Merged
merged 6 commits into from
Feb 22, 2024
Merged

MEP #1548

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/AdminController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class AdminController(
(recipient =>
ConsumerReportAcknowledgment(
genReport.copy(
status = ReportStatus.NA,
status = ReportStatus.TraitementEnCours,
tags = List(ReportTag.ProduitDangereux),
email = recipient
),
Expand Down
3 changes: 2 additions & 1 deletion app/models/report/socialnetwork/CertifiedInfluencer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import models.report.SocialNetworkSlug
import play.api.libs.json.Json
import play.api.libs.json.OFormat

import java.time.OffsetDateTime
import java.util.UUID

case class CertifiedInfluencer(id: UUID, socialNetwork: SocialNetworkSlug, name: String)
case class CertifiedInfluencer(id: UUID, socialNetwork: SocialNetworkSlug, name: String, creationDate: OffsetDateTime)

object CertifiedInfluencer {
implicit val format: OFormat[CertifiedInfluencer] = Json.format[CertifiedInfluencer]
Expand Down
5 changes: 4 additions & 1 deletion app/orchestrators/socialmedia/InfluencerOrchestrator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import models.report.SocialNetworkSlug
import models.report.socialnetwork.CertifiedInfluencer
import repositories.influencer.InfluencerRepositoryInterface

import java.time.OffsetDateTime
import java.util.UUID
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
Expand All @@ -23,7 +24,9 @@ class InfluencerOrchestrator(
} else {
socialBladeClient.checkSocialNetworkUsername(socialNetwork, curated).flatMap { existsOnSocialBlade =>
if (existsOnSocialBlade) {
influencerRepository.create(CertifiedInfluencer(UUID.randomUUID(), socialNetwork, curated)).map(_ => true)
influencerRepository
.create(CertifiedInfluencer(UUID.randomUUID(), socialNetwork, curated, OffsetDateTime.now()))
.map(_ => true)
} else {
Future.successful(false)
}
Expand Down
14 changes: 12 additions & 2 deletions app/repositories/company/CompanyRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import repositories.CRUDRepository
import slick.basic.DatabaseConfig
import utils.Constants.ActionEvent.POST_FOLLOW_UP_DOC
import utils.Constants.ActionEvent.REPORT_CLOSED_BY_NO_READING
import utils.Constants.Departments.toPostalCode

import java.sql.Timestamp
import java.time.OffsetDateTime
Expand Down Expand Up @@ -53,8 +54,17 @@ class CompanyRepository(override val dbConfig: DatabaseConfig[JdbcProfile])(impl
val query = table
.joinLeft(ReportTable.table(Some(userRole)))
.on(_.id === _.companyId)
.filterIf(search.departments.nonEmpty) { case (company, _) =>
company.department.map(a => a.inSet(search.departments)).getOrElse(false)
// .filterIf(search.departments.nonEmpty) { case (company, _) =>
// company.department.map(a => a.inSet(search.departments)).getOrElse(false)
// }
.filterIf(search.departments.nonEmpty) { case (company, report) =>
val departmentsFilter: Rep[Boolean] = search.departments
.flatMap(toPostalCode)
.map(dep => company.department.asColumnOf[String] like s"${dep}%")
.reduceLeft(_ || _)
// Avoid searching departments in foreign countries
departmentsFilter && report.map(_.companyCountry).isEmpty

}
.filterIf(search.activityCodes.nonEmpty) { case (company, _) =>
company.activityCode.map(a => a.inSet(search.activityCodes)).getOrElse(false)
Expand Down
8 changes: 6 additions & 2 deletions app/repositories/influencer/InfluencerTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import repositories.DatabaseTable
import repositories.PostgresProfile.api._
import slick.ast.TypedType

import java.time.OffsetDateTime

class InfluencerTable(tag: Tag)(implicit tt: TypedType[SocialNetworkSlug])
extends DatabaseTable[CertifiedInfluencer](tag, "influencers") {
def socialNetwork = column[SocialNetworkSlug]("social_network")

def name = column[String]("name")
def name = column[String]("name")
def creationDate = column[OffsetDateTime]("creation_date")

override def * = (id, socialNetwork, name) <> ((CertifiedInfluencer.apply _).tupled, CertifiedInfluencer.unapply)
override def * =
(id, socialNetwork, name, creationDate) <> ((CertifiedInfluencer.apply _).tupled, CertifiedInfluencer.unapply)
}

object InfluencerTable {
Expand Down
13 changes: 12 additions & 1 deletion app/views/mails/consumer/reportAcknowledgment.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@
@Messages("ReportAckEmail.vendorName", report.vendor.get)
<br/>
}
@if(report.influencer.isDefined) {
@Messages("ReportAckEmail.influencerName", report.influencer.map(_.name).getOrElse(""))
<br/>
@Messages("ReportAckEmail.socialNetwork", report.influencer.flatMap(_.socialNetwork.map(_.entryName))
.orElse(report.influencer.flatMap(_.otherSocialNetwork)).getOrElse(""))
<br/>
}

<br />
<b>@Messages("ReportAckEmail.consumer")</b>
Expand All @@ -225,7 +232,11 @@
@Messages("ReportAckEmail.email", report.email)
<br/>
@if(report.visibleToPro) {
@Messages("ReportAckEmail.contactAgreement", if(report.contactAgreement) {Messages("ReportAckEmail.yes")} else {Messages("ReportAckEmail.no")})
@Messages("ReportAckEmail.contactAgreement", if(report.contactAgreement) {
Messages("ReportAckEmail.yes")
} else {
Messages("ReportAckEmail.no")
})
<br/>
}
</div>
Expand Down
2 changes: 2 additions & 0 deletions conf/db/migration/default/V21__influencer_creationdate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE influencers
ADD creation_date timestamp with time zone default now() not null;
2 changes: 2 additions & 0 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ ReportAckEmail.yes=yes
ReportAckEmail.no=no
ReportAckEmail.understandSignalConso=Understanding SignalConso
ReportAckEmail.yourReport=Your report
ReportAckEmail.influencerName=Influencer: {0}
ReportAckEmail.socialNetwork=Social network: {0}

reportPDF.page.title=Report Details {0}
reportPDF.references.uniqueId=Unique Identifier: {0}
Expand Down
2 changes: 2 additions & 0 deletions conf/messages.fr
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ ReportAckEmail.yes=oui
ReportAckEmail.no=non
ReportAckEmail.understandSignalConso=Comprendre SignalConso
ReportAckEmail.yourReport=Votre signalement
ReportAckEmail.influencerName=Influenceur: {0}
ReportAckEmail.socialNetwork=Plateforme: {0}

reportPDF.page.title=Détail du signalement {0}
reportPDF.references.uniqueId=Identifiant unique : {0}
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Dependencies {
lazy val playJsonExtensionsVersion = "0.42.0"
lazy val awsJavaSdkS3Version = "1.12.603"
lazy val jacksonModuleScalaVersion = "2.16.0"
lazy val postgresqlVersion = "42.5.4"
lazy val postgresqlVersion = "42.5.5"
lazy val refinedVersion = "0.11.0"
lazy val spoiwoVersion = "2.2.1"
lazy val itext7CoreVersion = "8.0.2"
Expand Down
Loading