From 1713b661b4a607e50204093608d93d2d3240ef0c Mon Sep 17 00:00:00 2001 From: eletallbetagouv <107104509+eletallbetagouv@users.noreply.github.com> Date: Tue, 28 Jan 2025 12:18:00 +0100 Subject: [PATCH] TRELLO-2881 document endpoints (and remove some unused ones) --- app/controllers/StaticController.scala | 17 - app/controllers/StatisticController.scala | 28 -- app/controllers/package.scala | 8 - app/loader/SignalConsoApplicationLoader.scala | 45 ++- app/models/Statistics.scala | 38 -- app/orchestrators/StatsOrchestrator.scala | 30 -- app/views/api.scala.html | 59 --- build.sbt | 4 +- conf/routes | 351 +++++++++++------- .../controllers/StatisticControllerSpec.scala | 13 - 10 files changed, 240 insertions(+), 353 deletions(-) delete mode 100644 app/controllers/StaticController.scala delete mode 100644 app/views/api.scala.html diff --git a/app/controllers/StaticController.scala b/app/controllers/StaticController.scala deleted file mode 100644 index 08634f21b..000000000 --- a/app/controllers/StaticController.scala +++ /dev/null @@ -1,17 +0,0 @@ -package controllers - -import authentication.Authenticator -import models.User -import play.api.mvc.ControllerComponents - -import scala.concurrent.ExecutionContext -import scala.concurrent.Future - -class StaticController(authenticator: Authenticator[User], controllerComponents: ControllerComponents)(implicit - val ec: ExecutionContext -) extends BaseController(authenticator, controllerComponents) { - - def api = UserAwareAction.async(parse.empty) { _ => - Future.successful(Ok(views.html.api())) - } -} diff --git a/app/controllers/StatisticController.scala b/app/controllers/StatisticController.scala index 4a401d250..af12930f3 100644 --- a/app/controllers/StatisticController.scala +++ b/app/controllers/StatisticController.scala @@ -74,34 +74,6 @@ class StatisticController( ) } - def getPublicStatCount(publicStat: PublicStat) = IpRateLimitedAction2.async { - ((publicStat.filter, publicStat.percentageBaseFilter) match { - case (filter, Some(percentageBaseFilter)) => - statsOrchestrator.getReportCountPercentageWithinReliableDates(None, filter, percentageBaseFilter) - case (filter, _) => - statsOrchestrator.getReportCount(None, filter) - }).map(curve => Ok(Json.toJson(curve))) - } - - def getPublicStatCurve(publicStat: PublicStat) = IpRateLimitedAction2.async { - ((publicStat.filter, publicStat.percentageBaseFilter) match { - case (filter, Some(percentageBaseFilter)) => - statsOrchestrator.getReportsCountPercentageCurve(None, filter, percentageBaseFilter) - case (filter, _) => - statsOrchestrator.getReportsCountCurve(None, filter) - }).map(curve => Ok(Json.toJson(curve))) - } - - def getDelayReportReadInHours(companyId: Option[UUID]) = SecuredAction - .andThen( - WithRole(UserRole.AdminsAndReadOnlyAndCCRF) - ) - .async { - statsOrchestrator - .getReadAvgDelay(companyId) - .map(count => Ok(Json.toJson(StatsValue(count.map(_.toHours.toInt))))) - } - def getDelayReportResponseInHours(companyId: Option[UUID]) = SecuredAction.async { request => statsOrchestrator .getResponseAvgDelay(companyId: Option[UUID], request.identity.userRole) diff --git a/app/controllers/package.scala b/app/controllers/package.scala index 544ab1c69..a08e707c3 100644 --- a/app/controllers/package.scala +++ b/app/controllers/package.scala @@ -10,7 +10,6 @@ import play.api.mvc.PathBindable import play.api.mvc.QueryStringBindable import play.api.mvc.Request import cats.syntax.either._ -import models.PublicStat import models.extractUUID import models.report.ReportFileOrigin import models.report.ReportResponseType @@ -91,13 +90,6 @@ package object controllers { reportAdminActionType => reportAdminActionType.entryName ) - implicit val PublicStatQueryStringBindable: QueryStringBindable[PublicStat] = - QueryStringBindable.bindableString - .transform[PublicStat]( - publicStat => PublicStat.withNameInsensitive(publicStat), - publicStat => publicStat.entryName - ) - implicit class RequestOps[T <: JsValue](request: Request[T])(implicit ec: ExecutionContext) { def parseBody[B](path: JsPath = JsPath())(implicit reads: Reads[B]) = request.body .validate[B](path.read[B]) diff --git a/app/loader/SignalConsoApplicationLoader.scala b/app/loader/SignalConsoApplicationLoader.scala index eb78b418a..36631496e 100644 --- a/app/loader/SignalConsoApplicationLoader.scala +++ b/app/loader/SignalConsoApplicationLoader.scala @@ -895,8 +895,6 @@ class SignalConsoComponents( controllerComponents ) - val staticController = new StaticController(cookieAuthenticator, controllerComponents) - val statisticController = new StatisticController(statsOrchestrator, cookieAuthenticator, controllerComponents) val subscriptionOrchestrator = new SubscriptionOrchestrator(subscriptionRepository) @@ -948,38 +946,37 @@ class SignalConsoComponents( new _root_.router.Routes( httpErrorHandler, new HealthController(controllerComponents), - staticController, - statisticController, - companyAccessController, - reportListController, - reportFileController, + assets, reportController, + socialNetworkController, + barcodeController, reportConsumerReviewController, - eventsController, + engagementController, + emailValidationController, + ratingController, + constantController, + reportListController, bookmarkController, - reportToExternalController, - dataEconomieController, - adminController, asyncFileController, - constantController, - socialNetworkController, - mobileAppController, + eventsController, + reportFileController, + adminController, + statisticController, + companyAccessController, authController, accountController, - emailValidationController, + blacklistedEmailsController, companyController, - ratingController, + importController, + reportBlockedNotificationController, subscriptionController, websiteController, - reportedPhoneController, - reportBlockedNotificationController, - blacklistedEmailsController, - signalConsoReviewController, siretExtractorController, - importController, - barcodeController, - engagementController, - assets + reportedPhoneController, + mobileAppController, + reportToExternalController, + dataEconomieController, + signalConsoReviewController ) def scheduleTasks() = { diff --git a/app/models/Statistics.scala b/app/models/Statistics.scala index 03f314cac..08dc21570 100644 --- a/app/models/Statistics.scala +++ b/app/models/Statistics.scala @@ -1,14 +1,5 @@ package models -import enumeratum.EnumEntry -import enumeratum.PlayEnum -import models.report.ReportStatus.statusReadByPro -import models.report.ReportStatus.statusWithProResponse -import models.report.ReportFilter -import models.report.ReportFilter.allReportsFilter -import models.report.ReportFilter.transmittedReportsFilter -import models.report.ReportStatus - import java.time.LocalDate import play.api.libs.json.Json import play.api.libs.json.OFormat @@ -37,32 +28,3 @@ case class ReportReviewStats( object ReportReviewStats { implicit val format: OFormat[ReportReviewStats] = Json.format[ReportReviewStats] } - -sealed abstract class PublicStat(val filter: ReportFilter, val percentageBaseFilter: Option[ReportFilter] = None) - extends EnumEntry - -object PublicStat extends PlayEnum[PublicStat] { - lazy val values = findValues - case object PromesseAction extends PublicStat(ReportFilter(status = Seq(ReportStatus.PromesseAction))) - case object Reports extends PublicStat(allReportsFilter) - case object TransmittedPercentage - extends PublicStat( - transmittedReportsFilter, - Some(allReportsFilter) - ) - case object ReadPercentage - extends PublicStat( - ReportFilter(status = statusReadByPro), - Some(transmittedReportsFilter) - ) - case object ResponsePercentage - extends PublicStat( - ReportFilter(status = statusWithProResponse), - Some(ReadPercentage.filter) - ) - case object WebsitePercentage - extends PublicStat( - ReportFilter(hasWebsite = Some(true)), - Some(allReportsFilter) - ) -} diff --git a/app/orchestrators/StatsOrchestrator.scala b/app/orchestrators/StatsOrchestrator.scala index d7ac265e5..23de16516 100644 --- a/app/orchestrators/StatsOrchestrator.scala +++ b/app/orchestrators/StatsOrchestrator.scala @@ -13,7 +13,6 @@ import models.report.delete.ReportAdminActionType import models.report.review.ResponseEvaluation import orchestrators.StatsOrchestrator.computeStartingDate import orchestrators.StatsOrchestrator.formatStatData -import orchestrators.StatsOrchestrator.restrictToReliableDates import orchestrators.StatsOrchestrator.toPercentage import repositories.accesstoken.AccessTokenRepositoryInterface import repositories.event.EventRepositoryInterface @@ -126,17 +125,6 @@ class StatsOrchestrator( baseCount <- reportRepository.count(user, basePercentageFilter) } yield toPercentage(count, baseCount) - def getReportCountPercentageWithinReliableDates( - user: Option[User], - filter: ReportFilter, - basePercentageFilter: ReportFilter - ): Future[Int] = - getReportCountPercentage( - user, - restrictToReliableDates(filter), - restrictToReliableDates(basePercentageFilter) - ) - def getReportsCountCurve( user: Option[User], reportFilter: ReportFilter, @@ -149,21 +137,6 @@ class StatsOrchestrator( case CurveTickDuration.Day => reportRepository.getDailyCount(user, reportFilter, ticks) } - def getReportsCountPercentageCurve( - user: Option[User], - reportFilter: ReportFilter, - baseFilter: ReportFilter - ): Future[Seq[CountByDate]] = - for { - rawCurve <- getReportsCountCurve(user, reportFilter) - baseCurve <- getReportsCountCurve(user, baseFilter) - } yield rawCurve.sortBy(_.date).zip(baseCurve.sortBy(_.date)).map { case (a, b) => - CountByDate( - count = toPercentage(a.count, b.count), - date = a.date - ) - } - def getReportsTagsDistribution(companyId: Option[UUID], user: User): Future[Map[ReportTag, Int]] = reportRepository.getReportsTagsDistribution(companyId, user) @@ -195,9 +168,6 @@ class StatsOrchestrator( } } - def getReadAvgDelay(companyId: Option[UUID] = None) = - eventRepository.getAvgTimeUntilEvent(ActionEvent.REPORT_READING_BY_PRO, companyId) - def getResponseAvgDelay(companyId: Option[UUID] = None, userRole: UserRole): Future[Option[Duration]] = { val onlyProShareable = userRole == UserRole.Professionnel eventRepository.getAvgTimeUntilEvent( diff --git a/app/views/api.scala.html b/app/views/api.scala.html deleted file mode 100644 index 940c8409b..000000000 --- a/app/views/api.scala.html +++ /dev/null @@ -1,59 +0,0 @@ -@() - - - - - - Description de l'API SignalConso - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheminMéthodeDescription
/api/authenticatePOSTAuthentification de l'utilisateur
/api/reports/:uuidGETRécupération d'un signalement par son identifiant
/api/reportsGETRécupération des signalements par page
/api/reportsPOSTCréation d'un signalement
/api/events/:uuidReportGETRécupération des évènements d'un signalement
/api/reports/statsGETRécupération des statistiques sur les signalements
/api/companiesGETRecherche textuelle d'entreprises
/api/companies/suggestGETRecherche textuelle de suggestions d'entreprises
- - \ No newline at end of file diff --git a/build.sbt b/build.sbt index 7489d3923..4a1242a9c 100644 --- a/build.sbt +++ b/build.sbt @@ -39,7 +39,6 @@ routesImport ++= Seq( "models.report.reportfile.ReportFileId", "models.report.ReportResponseType", "models.report.delete.ReportAdminActionType", - "models.PublicStat", "controllers.IdentificationStatusQueryStringBindable", "controllers.WebsiteIdPathBindable", "controllers.UUIDPathBindable", @@ -48,8 +47,7 @@ routesImport ++= Seq( "controllers.ReportFileIdPathBindable", "controllers.ReportResponseTypeQueryStringBindable", "controllers.ReportAdminActionTypeQueryStringBindable", - "controllers.ReportFileOriginQueryStringBindable", - "controllers.PublicStatQueryStringBindable" + "controllers.ReportFileOriginQueryStringBindable" ) semanticdbVersion := scalafixSemanticdb.revision diff --git a/conf/routes b/conf/routes index 6ff094a15..2bd33bb94 100644 --- a/conf/routes +++ b/conf/routes @@ -1,109 +1,166 @@ - # Routes -# This file defines all application routes (Higher priority routes first) -# ~~~~ +############################# +########### BASICS ########## +############################# + GET / controllers.HealthController.health -# Static pages -GET /api controllers.StaticController.api +GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) + +############################################# +##### FOR THE CONSO, FROM THE WEBSITE ####### +############################################# + +POST /api/reports controllers.ReportController.createReport() +# Recherche de nom d'influenceur pour voir s'il existe +GET /api/certified-influencer controllers.SocialNetworkController.get(name:String, socialNetwork: String) +# Recherche de code barres +GET /api/barcode/gtin/:gtin controllers.BarcodeController.getProductByGTIN(gtin) +# to post his review +POST /api/reports/:uuid/response/review controllers.ReportConsumerReviewController.reviewOnReportResponse(uuid: java.util.UUID) +GET /api/reports/:uuid/response/review/exists controllers.ReportConsumerReviewController.reviewExists(uuid: java.util.UUID) +POST /api/reports/:uuid/engagement/review controllers.EngagementController.reviewEngagementOnReportResponse(uuid: java.util.UUID) +GET /api/reports/:uuid/engagement/review/exists controllers.EngagementController.engagementReviewExists(uuid: java.util.UUID) +# validation of the conso's email +POST /api/email-validation/check controllers.EmailValidationController.check() +POST /api/email-validation/validate controllers.EmailValidationController.validate() +POST /api/email-validation/check-and-validate controllers.EmailValidationController.checkAndValidate() +# pour poster une évaluation (thumbs up/down) sur une sous-cat +POST /api/rating controllers.RatingController.rate() +# egalement utilisé dans le dashboard +GET /api/constants/countries controllers.ConstantController.getCountries() -# Statistics API -GET /api/stats/reports/public/count controllers.StatisticController.getPublicStatCount(publicStat: PublicStat) -GET /api/stats/reports/public/curve controllers.StatisticController.getPublicStatCurve(publicStat: PublicStat) -GET /api/stats/reports/count controllers.StatisticController.getReportsCount() -GET /api/stats/reports/curve controllers.StatisticController.getReportsCountCurve() -GET /api/stats/reports/delay/responsed controllers.StatisticController.getDelayReportResponseInHours(companyId: Option[java.util.UUID]) -GET /api/stats/reports/delay/read controllers.StatisticController.getDelayReportReadInHours(companyId: Option[java.util.UUID]) -GET /api/stats/reports/tags controllers.StatisticController.getReportsTagsDistribution(companyId: Option[java.util.UUID]) -GET /api/stats/reports/status controllers.StatisticController.getReportsStatusDistribution(companyId: Option[java.util.UUID]) -GET /api/stats/reports/accepted controllers.StatisticController.getAcceptedResponsesDistribution(companyId: java.util.UUID) -GET /api/stats/reports/reviews controllers.StatisticController.getReportResponseReviews(companyId: Option[java.util.UUID]) -GET /api/stats/reports/engagement-reviews controllers.StatisticController.getReportEngagementReviews(companyId: Option[java.util.UUID]) -GET /api/stats/reports/pro-totransmit controllers.StatisticController.getProReportToTransmitStat() -GET /api/stats/reports/pro-transmitted controllers.StatisticController.getProReportTransmittedStat() -GET /api/stats/reports/pro-response controllers.StatisticController.getProReportResponseStat(responseStatusQuery: Option[List[ReportResponseType]]) -GET /api/stats/pro-account-rate controllers.CompanyAccessController.proFirstActivationCount(ticks: Option[Int]) -GET /api/stats/dgccrf-account controllers.StatisticController.dgccrfAccountsCurve(ticks: Option[Int]) -GET /api/stats/dgccrf-active-account controllers.StatisticController.dgccrfActiveAccountsCurve(ticks: Option[Int]) -GET /api/stats/dgccrf-subscriptions controllers.StatisticController.dgccrfSubscription(ticks: Option[Int]) -GET /api/stats/dgccrf-controls controllers.StatisticController.dgccrfControlsCurve(ticks: Option[Int]) -GET /api/stats/count-by-adminactions controllers.StatisticController.fetchAdminActionEvents(companyId: java.util.UUID,reportAdminActionType: ReportAdminActionType) -GET /api/reports/count-by-departments controllers.StatisticController.countByDepartments() -GET /api/reports/count-by-subcategories controllers.StatisticController.reportsCountBySubcategories() -GET /api/reports/count-by-subcategories/download controllers.StatisticController.downloadReportsCountBySubcategories(lang: String) +########################################### +########## REPORTS SEARCH/LIST PAGE ####### +########################################### -# Reports list API GET /api/reports controllers.ReportListController.getReports() POST /api/reports/extract controllers.ReportListController.extractReports() +# button "download" which appears after selecting some reports +# also for the report page, button "download", if there are no attached files (or if there are but you pick the option to not get them) +GET /api/reports/download controllers.ReportController.reportsAsPDF() +GET /api/reports/bookmarks/count controllers.BookmarkController.countBookmarks() +# also used in the report page +DELETE /api/reports/:uuid/bookmark controllers.BookmarkController.removeBookmark(uuid: java.util.UUID) +POST /api/reports/:uuid/bookmark controllers.BookmarkController.addBookmark(uuid: java.util.UUID) +# pour visualiser les exports excels qui sont générés en asynchrone +# également utilisé pour les pages Excel "Sites non identifiés" et les "Téléphones signalés" +GET /api/async-files controllers.AsyncFileController.listAsyncFiles(kind: Option[String]) + +############################## +########## REPORT PAGE ####### +############################## + +GET /api/reports/:uuid controllers.ReportController.getReport(uuid: java.util.UUID) +GET /api/reports/:uuid/events controllers.EventsController.getReportEvents(uuid: java.util.UUID, eventType: Option[String]) +GET /api/reports/:uuid/response/review controllers.ReportConsumerReviewController.getReview(uuid: java.util.UUID) +GET /api/reports/:uuid/engagement/review controllers.EngagementController.getEngagementReview(uuid: java.util.UUID) +GET /api/barcode/:id controllers.BarcodeController.getById(id: java.util.UUID) +# button "download", if there's attached files and you pick the corresponding option +GET /api/reports/download-with-attachments/:reportId controllers.ReportController.reportAsZip(reportId: java.util.UUID) +# for the pro, to post his response +POST /api/reports/:uuid/response controllers.ReportController.reportResponse(uuid: java.util.UUID) +# for the pro to assign a report +POST /api/reports/:uuid/assign/:userId controllers.ReportController.updateReportAssignedUser(uuid: java.util.UUID, userId: java.util.UUID) -# Report API +######################################################################## +########## FOR VIEWING/EDITING ATTACHMENTS OF AN EXISTING REPORT ####### +######################################################################## + +# button "download all attachments" GET /api/reports/files controllers.ReportFileController.downloadZip(reportId: java.util.UUID, origin : Option[ReportFileOrigin]) +# for direct download of a single attachment GET /api/reports/files/:uuid/:filename controllers.ReportFileController.downloadReportFile(uuid: ReportFileId, filename) +# for deletion of a single attachment DELETE /api/reports/files/:uuid/:filename controllers.ReportFileController.deleteReportFile(uuid: ReportFileId, filename) +# for adding a single attachment (for both pro and admin) POST /api/reports/files controllers.ReportFileController.uploadReportFile(reportFileId: Option[java.util.UUID]) +# something related to the antivirus scan of the files (but I couldn't find how to trigger it) POST /api/reports/files/list controllers.ReportFileController.retrieveReportFiles() -GET /api/reports/download controllers.ReportController.reportsAsPDF() -GET /api/reports/download-with-attachments/:reportId controllers.ReportController.reportAsZip(reportId: java.util.UUID) -GET /api/reports/cloudword/:companyId controllers.ReportController.cloudWord(companyId: java.util.UUID) -POST /api/reports/reopen controllers.ReportController.reopenReport() -GET /api/reports/:uuid controllers.ReportController.getReport(uuid: java.util.UUID) -DELETE /api/reports/:uuid controllers.ReportController.deleteReport(uuid: java.util.UUID) -DELETE /api/reports controllers.ReportController.deleteSpamReport() +################################################################# +### ACTIONS (ADMIN PRINCIPALEMENT) SUR UN SIGNALEMENT ########## +################################################################# -POST /api/reports controllers.ReportController.createReport() -POST /api/reports/:uuid/response controllers.ReportController.reportResponse(uuid: java.util.UUID) -POST /api/reports/:uuid/response/review controllers.ReportConsumerReviewController.reviewOnReportResponse(uuid: java.util.UUID) -GET /api/reports/:uuid/response/review controllers.ReportConsumerReviewController.getReview(uuid: java.util.UUID) -GET /api/reports/:uuid/response/review/exists controllers.ReportConsumerReviewController.reviewExists(uuid: java.util.UUID) -POST /api/reports/:uuid/assign/:userId controllers.ReportController.updateReportAssignedUser(uuid: java.util.UUID, userId: java.util.UUID) +# action admin pour agir sur un signalement, le modifier, etc. POST /api/reports/:uuid/company controllers.ReportController.updateReportCompany(uuid: java.util.UUID) PUT /api/reports/:uuid/country controllers.ReportController.updateReportCountry(uuid: java.util.UUID, countryCode: String) POST /api/reports/:uuid/consumer controllers.ReportController.updateReportConsumer(uuid: java.util.UUID) -POST /api/reports/:uuid/action controllers.ReportController.createReportAction(uuid: java.util.UUID) GET /api/reports/:uuid/consumer-email-pdf controllers.ReportController.generateConsumerReportEmailAsPDF(uuid: java.util.UUID) -GET /api/reports/:uuid/events controllers.EventsController.getReportEvents(uuid: java.util.UUID, eventType: Option[String]) -POST /api/reports/:uuid/bookmark controllers.BookmarkController.addBookmark(uuid: java.util.UUID) -DELETE /api/reports/:uuid/bookmark controllers.BookmarkController.removeBookmark(uuid: java.util.UUID) -GET /api/reports/bookmarks/count controllers.BookmarkController.countBookmarks() -GET /api/companies/:siret/events controllers.EventsController.getCompanyEvents(siret: SIRET, eventType: Option[String]) +# button "reopen" that appears to admin in certain cases +# this button also appears in the reports search page, after selecting some suitable reports +POST /api/reports/reopen controllers.ReportController.reopenReport() +# for "Action administrateur" popin. Note : it is not always a deletion! +DELETE /api/reports/:uuid controllers.ReportController.deleteReport(uuid: java.util.UUID) +# fourre-tout de diverses action admin/agent/pro (ajout de pièces jointes, commentaires, marquer un contrôle effectué) +POST /api/reports/:uuid/action controllers.ReportController.createReportAction(uuid: java.util.UUID) +# Analyse IA +POST /api/albert/classification/:reportId controllers.AdminController.classifyAndSummarize(reportId: java.util.UUID) +GET /api/albert/classification/:reportId controllers.AdminController.getAlbertClassification(reportId: java.util.UUID) +############################### +########## COMPANY PAGE ####### +############################### -# Report API for externals SI -GET /api/ext/reports/siret/:siret controllers.ReportToExternalController.searchReportsToExternalBySiret(siret: String) -GET /api/ext/reports/extract controllers.DataEconomieController.reportDataEcomonie() -GET /api/ext/reports controllers.ReportToExternalController.searchReportsToExternal() -GET /api/ext/v2/reports controllers.ReportToExternalController.searchReportsToExternalV2() -GET /api/ext/reports/:uuid controllers.ReportToExternalController.getReportToExternal(uuid) +GET /api/companies/:siret/events controllers.EventsController.getCompanyEvents(siret: SIRET, eventType: Option[String]) +# various stats for the company page +GET /api/stats/reports/delay/responsed controllers.StatisticController.getDelayReportResponseInHours(companyId: Option[java.util.UUID]) +GET /api/stats/reports/tags controllers.StatisticController.getReportsTagsDistribution(companyId: Option[java.util.UUID]) +GET /api/stats/reports/status controllers.StatisticController.getReportsStatusDistribution(companyId: Option[java.util.UUID]) +GET /api/stats/reports/accepted controllers.StatisticController.getAcceptedResponsesDistribution(companyId: java.util.UUID) +GET /api/stats/reports/reviews controllers.StatisticController.getReportResponseReviews(companyId: Option[java.util.UUID]) +GET /api/stats/reports/engagement-reviews controllers.StatisticController.getReportEngagementReviews(companyId: Option[java.util.UUID]) +GET /api/stats/count-by-adminactions controllers.StatisticController.fetchAdminActionEvents(companyId: java.util.UUID,reportAdminActionType: ReportAdminActionType) +GET /api/reports/cloudword/:companyId controllers.ReportController.cloudWord(companyId: java.util.UUID) -# Admin API +##################################### +#### PAGE "STATISTIQUES" ############ +##################################### + +# tab "Signalements" +GET /api/stats/reports/count controllers.StatisticController.getReportsCount() +GET /api/stats/reports/curve controllers.StatisticController.getReportsCountCurve() +GET /api/reports/count-by-departments controllers.StatisticController.countByDepartments() +# tab "Professionnels" +GET /api/stats/reports/pro-totransmit controllers.StatisticController.getProReportToTransmitStat() +GET /api/stats/reports/pro-transmitted controllers.StatisticController.getProReportTransmittedStat() +GET /api/stats/reports/pro-response controllers.StatisticController.getProReportResponseStat(responseStatusQuery: Option[List[ReportResponseType]]) +GET /api/stats/pro-account-rate controllers.CompanyAccessController.proFirstActivationCount(ticks: Option[Int]) +# tab "DGGCCRF" +GET /api/stats/dgccrf-account controllers.StatisticController.dgccrfAccountsCurve(ticks: Option[Int]) +GET /api/stats/dgccrf-active-account controllers.StatisticController.dgccrfActiveAccountsCurve(ticks: Option[Int]) +GET /api/stats/dgccrf-subscriptions controllers.StatisticController.dgccrfSubscription(ticks: Option[Int]) +GET /api/stats/dgccrf-controls controllers.StatisticController.dgccrfControlsCurve(ticks: Option[Int]) +# tab "Signalements par sous-categories" +GET /api/reports/count-by-subcategories controllers.StatisticController.reportsCountBySubcategories() +GET /api/reports/count-by-subcategories/download controllers.StatisticController.downloadReportsCountBySubcategories(lang: String) +##################################### +########## PAGE "OUTILS" ############ +##################################### +# tab "Outils de tests" GET /api/admin/test-email controllers.AdminController.getEmailCodes() POST /api/admin/test-email controllers.AdminController.sendTestEmail(templateRef, to) GET /api/admin/test-pdf controllers.AdminController.getPdfCodes() POST /api/admin/test-pdf controllers.AdminController.sendTestPdf(templateRef) +# tab "Outils d'administration" +POST /api/admin/regen-sample-data controllers.AdminController.regenSampleData() +POST /api/admin/emails/resend controllers.AdminController.resend(start: OffsetDateTime, end: OffsetDateTime, emailType: models.ResendEmailType) +DELETE /api/reports controllers.ReportController.deleteSpamReport() +GET /api/blacklisted-ips controllers.AdminController.blackListedIPs() +POST /api/blacklisted-ips controllers.AdminController.createBlacklistedIp() +DELETE /api/blacklisted-ips/:ip controllers.AdminController.deleteBlacklistedIp(ip: String) + +# Those 3 seem unused. Probably ancien versions of "/api/admin/emails/resend" POST /api/admin/emails/reportAckToConsumer controllers.AdminController.sendReportAckToConsumer() POST /api/admin/emails/proAckToConsumer controllers.AdminController.sendProAckToConsumer() POST /api/admin/emails/newReportToPro controllers.AdminController.sendNewReportToPro() -POST /api/admin/emails/resend controllers.AdminController.resend(start: OffsetDateTime, end: OffsetDateTime, emailType: models.ResendEmailType) -POST /api/admin/regen-sample-data controllers.AdminController.regenSampleData() - -# Async files API -GET /api/async-files controllers.AsyncFileController.listAsyncFiles(kind: Option[String]) -# Events API +############################## +######## AUTHENTICATION ###### +############################## -# Constants API -GET /api/constants/countries controllers.ConstantController.getCountries() -GET /api/constants/categories controllers.ConstantController.getCategories() -GET /api/certified-influencer controllers.SocialNetworkController.get(name:String, socialNetwork: String) -GET /api/constants/categoriesByStatus controllers.ConstantController.getCategoriesByStatus() - -# Mobile app specific API -GET /api/mobileapp/requirements controllers.MobileAppController.getRequirements() - -# Authentication API POST /api/authenticate controllers.AuthController.authenticate() GET /api/authenticate/proconnect/start controllers.AuthController.startProConnectAuthentication(state: String, nonce:String) GET /api/authenticate/proconnect controllers.AuthController.proConnectAuthenticate(code: String, state: String) @@ -113,10 +170,17 @@ POST /api/logout/proconnect controller GET /api/current-user controllers.AuthController.getUser() POST /api/authenticate/password/forgot controllers.AuthController.forgotPassword() POST /api/authenticate/password/reset controllers.AuthController.resetPassword(token: java.util.UUID) -POST /api/account/password controllers.AuthController.changePassword() -GET /api/auth-attempts controllers.AuthController.listAuthAttempts(login: Option[String], offset: Option[Long], limit: Option[Int]) +POST /api/account/validate-email controllers.AccountController.validateEmail() +# process d'activation des comptes agents +GET /api/account/token controllers.AccountController.fetchTokenInfo(token: String) +# process d'activation des comptes pro et agents +POST /api/account/activation controllers.AccountController.activateAccount() + + +###################################### +######## USER ACCESSES TO COMPANY #### +###################################### -# Accesses API GET /api/accesses/connected-user controllers.CompanyAccessController.myCompanies() GET /api/accesses/visible-users controllers.CompanyAccessController.visibleUsersToPro() POST /api/accesses/visible-users/:email controllers.CompanyAccessController.inviteProToMyCompanies(email: String) @@ -133,32 +197,45 @@ POST /api/accesses/:siret/token/accept controller DELETE /api/accesses/:siret/token/:tokenId controllers.CompanyAccessController.removePendingToken(siret: String, tokenId: java.util.UUID) POST /api/accesses/:siret/invitation controllers.CompanyAccessController.sendInvitation(siret: String) -# Account API -GET /api/account/token controllers.AccountController.fetchTokenInfo(token: String) -POST /api/account/activation controllers.AccountController.activateAccount() -POST /api/account/admin/invitation controllers.AccountController.sendAdminInvitation(role: UserRole) +########################################### +######## PAGE "UTILISATEURS" ############## +########################################### + +# tab "Agents" +GET /api/account/agent/users controllers.AccountController.fetchAgentUsers() POST /api/account/agent/invitation controllers.AccountController.sendAgentInvitation(role: UserRole) POST /api/account/agent/invitations controllers.AccountController.sendAgentsInvitations(role: UserRole) +POST /api/account/validate-email/:email controllers.AccountController.forceValidateEmail(email : String) +# (également utilisé sur le tab des Admins) +DELETE /api/account/:id controllers.AccountController.softDelete(id: java.util.UUID) +# tab "Agents en attente" GET /api/account/agent/pending controllers.AccountController.fetchPendingAgent(role: Option[UserRole]) -GET /api/account/agent/users controllers.AccountController.fetchAgentUsers() +# tab "Admins" GET /api/account/admin/users controllers.AccountController.fetchAdminUsers() -GET /api/account/all/deleted-users controllers.AccountController.fetchAllSoftDeletedUsers() -POST /api/account/validate-email controllers.AccountController.validateEmail() -POST /api/account/validate-email/:email controllers.AccountController.forceValidateEmail(email : String) +POST /api/account/admin/invitation controllers.AccountController.sendAdminInvitation(role: UserRole) +# tab "Consos non validés" +GET /api/email-validation/search controllers.EmailValidationController.search() +# tab "Historique de connexion" +GET /api/auth-attempts controllers.AuthController.listAuthAttempts(login: Option[String], offset: Option[Long], limit: Option[Int]) +# tab "Liste noire des consos" +GET /api/blacklisted-emails controllers.BlacklistedEmailsController.list() +POST /api/blacklisted-emails controllers.BlacklistedEmailsController.add() +DELETE /api/blacklisted-emails/:uuid controllers.BlacklistedEmailsController.delete(uuid: java.util.UUID) + + +################################### +####### Page "PARAMETRES" ######### +################################### + PUT /api/account controllers.AccountController.edit() -DELETE /api/account/:id controllers.AccountController.softDelete(id: java.util.UUID) +POST /api/account/password controllers.AuthController.changePassword() POST /api/account/send-email-update-validation controllers.AccountController.sendEmailAddressUpdateValidation() PUT /api/account/update-email/:token controllers.AccountController.updateEmailAddress(token: String) -# EmailValidation API -POST /api/email-validation/check controllers.EmailValidationController.check() -POST /api/email-validation/validate controllers.EmailValidationController.validate() -POST /api/email-validation/check-and-validate controllers.EmailValidationController.checkAndValidate() -GET /api/email-validation/search controllers.EmailValidationController.search() +######################################### +######## PAGE "ENTREPRISES" ############# +######################################### - - -# Company details API POST /api/companies controllers.CompanyController.create() GET /api/companies controllers.CompanyController.searchRegistered() GET /api/companies/connected-user controllers.CompanyController.visibleCompanies() @@ -176,24 +253,27 @@ PUT /api/companies/:id/address controller GET /api/companies/:id/response-rate controllers.CompanyController.getResponseRate(id: java.util.UUID) GET /api/companies/:companyId controllers.CompanyController.searchById(companyId: java.util.UUID) GET /api/companies/:id/albert-problems controllers.CompanyController.getProblemsSeenByAlbert(id: java.util.UUID) +# bouton "Ouvrir des acces" +POST /api/import/companies controllers.ImportController.importUsers() +# gestion des "Notifications par email" (pour le pro) +GET /api/report-blocked-notification controllers.ReportBlockedNotificationController.getAll() +POST /api/report-blocked-notification controllers.ReportBlockedNotificationController.create() +POST /api/report-blocked-notification/delete controllers.ReportBlockedNotificationController.delete() +################################## +######## ABONNEMENTS ############# +################################## -# Rating API -POST /api/rating controllers.RatingController.rate() - -# Subscription API GET /api/subscriptions controllers.SubscriptionController.getSubscriptions() POST /api/subscriptions controllers.SubscriptionController.createSubscription() PUT /api/subscriptions/:subscriptionId controllers.SubscriptionController.updateSubscription(subscriptionId: java.util.UUID) GET /api/subscriptions/:subscriptionId controllers.SubscriptionController.getSubscription(subscriptionId: java.util.UUID) DELETE /api/subscriptions/:subscriptionId controllers.SubscriptionController.removeSubscription(subscriptionId: java.util.UUID) +################################################# +######## PAGE "SITES WEBS SIGNALES" ############# +################################################# -# ressources -GET /api/resources/investigation-status controllers.WebsiteController.listInvestigationStatus() - -POST /api/website-investigations controllers.WebsiteController.updateInvestigation() -# Websites API GET /api/websites controllers.WebsiteController.fetchWithCompanies(host: Option[String], identificationStatus: Option[Seq[IdentificationStatus]], offset: Option[Long], limit: Option[Int],investigationStatus: Option[Seq[InvestigationStatus]],start: Option[OffsetDateTime],end: Option[OffsetDateTime],hasAssociation: Option[Boolean],isOpen: Option[Boolean],isMarketplace: Option[Boolean]) POST /api/websites controllers.WebsiteController.create() GET /api/websites/search-url controllers.WebsiteController.searchByHost(url: String) @@ -203,45 +283,50 @@ PUT /api/websites/:id/company controller PUT /api/websites/:id/country controllers.WebsiteController.updateCompanyCountry(id: WebsiteId, companyCountry : String) PUT /api/websites/:id controllers.WebsiteController.updateWebsite(id: WebsiteId, identificationStatus :Option[IdentificationStatus], isMarketPlace: Option[Boolean]) DELETE /api/websites/:id controllers.WebsiteController.remove(id: WebsiteId) +GET /api/resources/investigation-status controllers.WebsiteController.listInvestigationStatus() +POST /api/website-investigations controllers.WebsiteController.updateInvestigation() +POST /api/extract-siret controllers.SiretExtractorController.extractSiret() + +############################################ +######## PAGE "TELEPHONES SIGNALES" ######## +############################################ -# Reported phones API GET /api/reported-phones controllers.ReportedPhoneController.fetchGrouped(q: Option[String], start: Option[String], end: Option[String], offset: Option[Long], limit: Option[Int]) GET /api/reported-phones/extract controllers.ReportedPhoneController.extractPhonesGroupBySIRET(q: Option[String], start: Option[String], end: Option[String]) -# Report notifications block list API -GET /api/report-blocked-notification controllers.ReportBlockedNotificationController.getAll() -POST /api/report-blocked-notification controllers.ReportBlockedNotificationController.create() -POST /api/report-blocked-notification/delete controllers.ReportBlockedNotificationController.delete() - -# Blacklist of some emails -GET /api/blacklisted-emails controllers.BlacklistedEmailsController.list() -POST /api/blacklisted-emails controllers.BlacklistedEmailsController.add() -DELETE /api/blacklisted-emails/:uuid controllers.BlacklistedEmailsController.delete(uuid: java.util.UUID) +######################################## +######## PAGE "MES ENGAGEMENTS" ######## +######################################## - # Blacklist of ips -GET /api/blacklisted-ips controllers.AdminController.blackListedIPs() -POST /api/blacklisted-ips controllers.AdminController.createBlacklistedIp() -DELETE /api/blacklisted-ips/:ip controllers.AdminController.deleteBlacklistedIp(ip: String) - -GET /api/review controllers.SignalConsoReviewController.signalConsoReview() +GET /api/engagements controllers.EngagementController.list() +POST /api/engagements/:id/check controllers.EngagementController.check(id: EngagementId) +POST /api/engagements/:id/uncheck controllers.EngagementController.uncheck(id: EngagementId) - # Siret extractor gateway -POST /api/extract-siret controllers.SiretExtractorController.extractSiret() +##################### +### MOBILE APP ###### +##################### -POST /api/import/companies controllers.ImportController.importUsers() -POST /api/import/marketplaces controllers.ImportController.importMarketplaces() +GET /api/mobileapp/requirements controllers.MobileAppController.getRequirements() +GET /api/constants/categories controllers.ConstantController.getCategories() +GET /api/constants/categoriesByStatus controllers.ConstantController.getCategoriesByStatus() -GET /api/barcode/gtin/:gtin controllers.BarcodeController.getProductByGTIN(gtin) -GET /api/barcode/:id controllers.BarcodeController.getById(id: java.util.UUID) +######################################## +########## FOR EXTERNAL SIs ############ +######################################## -GET /api/engagements controllers.EngagementController.list() -POST /api/engagements/:id/check controllers.EngagementController.check(id: EngagementId) -POST /api/engagements/:id/uncheck controllers.EngagementController.uncheck(id: EngagementId) -POST /api/reports/:uuid/engagement/review controllers.EngagementController.reviewEngagementOnReportResponse(uuid: java.util.UUID) -GET /api/reports/:uuid/engagement/review controllers.EngagementController.getEngagementReview(uuid: java.util.UUID) -GET /api/reports/:uuid/engagement/review/exists controllers.EngagementController.engagementReviewExists(uuid: java.util.UUID) +# celui-ci est marqué deprecated dans le code, qui dit d'utiliser /api/ext/reports (lui même remplacé par V2 ?) +GET /api/ext/reports/siret/:siret controllers.ReportToExternalController.searchReportsToExternalBySiret(siret: String) +GET /api/ext/reports controllers.ReportToExternalController.searchReportsToExternal() +GET /api/ext/v2/reports controllers.ReportToExternalController.searchReportsToExternalV2() +GET /api/ext/reports/extract controllers.DataEconomieController.reportDataEcomonie() +GET /api/ext/reports/:uuid controllers.ReportToExternalController.getReportToExternal(uuid) -POST /api/albert/classification/:reportId controllers.AdminController.classifyAndSummarize(reportId: java.util.UUID) -GET /api/albert/classification/:reportId controllers.AdminController.getAlbertClassification(reportId: java.util.UUID) +############################################################## +######## AUTRES ENDPOINTS SANS FRONTEND CORRESPONDANT ######## +############################################################## -GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) \ No newline at end of file +POST /api/import/marketplaces controllers.ImportController.importMarketplaces() +# pour debug potentiel +GET /api/account/all/deleted-users controllers.AccountController.fetchAllSoftDeletedUsers() +# semble inutilisé (table vide en prod) +GET /api/review controllers.SignalConsoReviewController.signalConsoReview() diff --git a/test/controllers/StatisticControllerSpec.scala b/test/controllers/StatisticControllerSpec.scala index d05ee1c0a..3017d8157 100644 --- a/test/controllers/StatisticControllerSpec.scala +++ b/test/controllers/StatisticControllerSpec.scala @@ -25,7 +25,6 @@ class ReportStatisticSpec extends StatisticControllerSpec { return reports count ${getReportCount} return reports curve ${getReportsCurve} return reports curve filted by status ${getReportsCurveFilteredByStatus} - return a public stat curve ${gePublicStatCurve} """ def aMonthlyStat(monthlyStat: CountByDate): Matcher[String] = @@ -77,18 +76,6 @@ class ReportStatisticSpec extends StatisticControllerSpec { ) } - def gePublicStatCurve = { - val request = - FakeRequest(GET, routes.StatisticController.getPublicStatCurve(PublicStat.PromesseAction).toString) - val result = route(app, request).get - status(result) must beEqualTo(OK) - val content = contentAsJson(result).toString - val startDate = LocalDate.now().withDayOfMonth(1) - content must haveMonthlyStats( - aMonthlyStat(CountByDate(lastMonthReportsAccepted.length, startDate.minusMonths(1L))), - aMonthlyStat(CountByDate(currentMonthReportsAccepted.length, startDate)) - ) - } } abstract class StatisticControllerSpec extends Specification with AppSpec with FutureMatchers with JsonMatchers {