mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-05-02 05:14:22 +02:00
Fixed issues not exporting when they disappear
This commit is contained in:
@@ -5,5 +5,5 @@ import models.profile.api._
|
||||
abstract class ExportPlatformTables[T, U] private[models] () {
|
||||
val tickets: TableQuery[_ <: ExportedVulnerabilities[T, U]]
|
||||
val projects: TableQuery[_ <: ExportedVulnerabilityProjects]
|
||||
def schema = tickets.schema ++ projects.schema
|
||||
def schema: models.profile.DDL = tickets.schema ++ projects.schema
|
||||
}
|
||||
|
||||
@@ -4,16 +4,19 @@ import models.profile.api._
|
||||
import slick.lifted.{MappedProjection, Tag}
|
||||
|
||||
|
||||
case class ExportedVulnerability[T] (vulnerabilityName: String, ticket: T, ticketFormatVersion: Int/*, maintainedAutomatically: Boolean*/)
|
||||
case class ExportedVulnerability[T] (vulnerabilityName: String, ticket: T, ticketFormatVersion: Int/*, maintainedAutomatically: Boolean*/, done: Boolean)
|
||||
|
||||
//noinspection TypeAnnotation
|
||||
abstract class ExportedVulnerabilities[T, U](tag: Tag, tableNamePart: String) extends Table[(Int, ExportedVulnerability[T])](tag, s"exported_${tableNamePart}_vulnerabilities"){
|
||||
def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
|
||||
def vulnerabilityName = column[String]("vulnerability_name")
|
||||
def ticketFormatVersion = column[Int]("ticket_format_version")
|
||||
def done = column[Boolean]("done")
|
||||
//def maintainedAutomatically = column[Boolean]("maintained_automatically")
|
||||
|
||||
def base: MappedProjection[ExportedVulnerability[T], U]// = (vulnerabilityName, ticket, ticketFormatVersion) <> ((ExportedVulnerability.apply[T] _).tupled, ExportedVulnerability.unapply[T])
|
||||
def * = (id, base)
|
||||
|
||||
def idx_vulnerabilityName = index(s"idx_${tableName}_vulnerabilityName", vulnerabilityName, unique = true)
|
||||
def idx_done = index(s"idx_${tableName}_done", done, unique = false)
|
||||
}
|
||||
@@ -23,24 +23,24 @@ package object models {
|
||||
val changelog = TableQuery[Changes]
|
||||
val notificationDigestStatuses = TableQuery[NotificationDigestStatuses]
|
||||
|
||||
val issueTrackerExportTables = new ExportPlatformTables[String, (String, String, Int)](){
|
||||
val issueTrackerExportTables = new ExportPlatformTables[String, (String, String, Int, Boolean)](){
|
||||
val tableNamePart = "issue_tracker"
|
||||
class IssueTrackerVulnerabilities(tag: Tag) extends ExportedVulnerabilities[String, (String, String, Int)](tag, tableNamePart){
|
||||
class IssueTrackerVulnerabilities(tag: Tag) extends ExportedVulnerabilities[String, (String, String, Int, Boolean)](tag, tableNamePart){
|
||||
def ticket = column[String]("ticket")
|
||||
override def base = (vulnerabilityName, ticket, ticketFormatVersion) <> ((ExportedVulnerability.apply[String] _).tupled, ExportedVulnerability.unapply[String])
|
||||
override def base = (vulnerabilityName, ticket, ticketFormatVersion, done) <> ((ExportedVulnerability.apply[String] _).tupled, ExportedVulnerability.unapply[String])
|
||||
def idx_ticket = index("idx_ticket", ticket, unique = true)
|
||||
}
|
||||
class IssueTrackerVulnerabilityProject(tag: Tag) extends ExportedVulnerabilityProjects(tag, tableNamePart)
|
||||
override val tickets = TableQuery[IssueTrackerVulnerabilities]
|
||||
override val projects: profile.api.TableQuery[_ <: ExportedVulnerabilityProjects] = TableQuery[IssueTrackerVulnerabilityProject]
|
||||
}
|
||||
type EmailExportedVulnerabilitiesShape = (String, EmailMessageId, Int)
|
||||
type EmailExportedVulnerabilitiesShape = (String, EmailMessageId, Int, Boolean)
|
||||
val mailExportTables = new ExportPlatformTables[EmailMessageId, EmailExportedVulnerabilitiesShape](){
|
||||
val tableNamePart = "email"
|
||||
class EmailExportedVulnerabilities(tag: Tag) extends ExportedVulnerabilities[EmailMessageId, EmailExportedVulnerabilitiesShape](tag, tableNamePart){
|
||||
private implicit val mmiMapper = MappedJdbcType.base[EmailMessageId, String](_.messageId, EmailMessageId)
|
||||
def messageId = column[EmailMessageId]("message_id") // Unlike ticket, message id is not required to be unique in order to handle some edge cases like play.mailer.mock = true
|
||||
override def base = (vulnerabilityName, messageId, ticketFormatVersion) <> ( (ExportedVulnerability.apply[EmailMessageId] _).tupled, ExportedVulnerability.unapply[EmailMessageId])
|
||||
override def base = (vulnerabilityName, messageId, ticketFormatVersion, done) <> ( (ExportedVulnerability.apply[EmailMessageId] _).tupled, ExportedVulnerability.unapply[EmailMessageId])
|
||||
}
|
||||
class EmailVulnerabilityProject(tag: Tag) extends ExportedVulnerabilityProjects(tag, tableNamePart)
|
||||
|
||||
@@ -48,12 +48,12 @@ package object models {
|
||||
override val tickets = TableQuery[EmailExportedVulnerabilities]
|
||||
}
|
||||
|
||||
val diffDbExportTables = new ExportPlatformTables[String, (String, Int)] {
|
||||
val diffDbExportTables = new ExportPlatformTables[String, (String, Int, Boolean)] {
|
||||
val tableNamePart = "diff_db"
|
||||
class DiffDbVulnerabilities(tag: Tag) extends ExportedVulnerabilities[String, (String, Int)](tag, tableNamePart){
|
||||
override def base: MappedProjection[ExportedVulnerability[String], (String, Int)] = (vulnerabilityName, ticketFormatVersion) <> (
|
||||
((n: String, v: Int) => ExportedVulnerability[String](n, n, v)).tupled,
|
||||
obj => ExportedVulnerability.unapply[String](obj).map{case (n, _, v) => (n, v)}
|
||||
class DiffDbVulnerabilities(tag: Tag) extends ExportedVulnerabilities[String, (String, Int, Boolean)](tag, tableNamePart){
|
||||
override def base: MappedProjection[ExportedVulnerability[String], (String, Int, Boolean)] = (vulnerabilityName, ticketFormatVersion, done) <> (
|
||||
((n: String, v: Int, d: Boolean) => ExportedVulnerability[String](n, n, v, d)).tupled,
|
||||
obj => ExportedVulnerability.unapply[String](obj).map{case (n, _, v, d) => (n, v, d)}
|
||||
)
|
||||
}
|
||||
class DiffDbVulnerabilityProject(tag: Tag) extends ExportedVulnerabilityProjects(tag, tableNamePart)
|
||||
@@ -65,7 +65,8 @@ package object models {
|
||||
/*{
|
||||
import profile.SchemaDescription
|
||||
val schema = Seq[Any{def schema: SchemaDescription}](
|
||||
notificationDigestStatuses
|
||||
//notificationDigestStatuses
|
||||
//diffDbExportTables, mailExportTables, issueTrackerExportTables
|
||||
).map(_.schema).foldLeft(profile.DDL(Seq(), Seq()))(_ ++ _)
|
||||
|
||||
val sql = Seq(
|
||||
@@ -76,7 +77,7 @@ package object models {
|
||||
schema.dropStatements.toSeq.map(_+";").mkString("\n").dropWhile(_ == "\n"),
|
||||
"\n"
|
||||
).mkString("\n")
|
||||
Files.write(Paths.get("conf/evolutions/default/8.sql"), sql.getBytes("utf-8"))
|
||||
Files.write(Paths.get("conf/evolutions/default/10.sql"), sql.getBytes("utf-8"))
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user