Reworking a bit and finalizing basic models.
All checks were successful
/ Build and Test Application Snapshot (pull_request) Successful in 1m42s

This commit is contained in:
Pat Garrity 2024-07-02 21:24:57 -05:00
parent d79d08dd68
commit 43abd31ede
Signed by: pfm
GPG key ID: 5CA5D21BAB7F3A76
5 changed files with 94 additions and 71 deletions

View file

@ -13,11 +13,14 @@ import gs.uuid.v0.UUID
* The unique slug for the group.
* @param createdAt
* The instant at which this group was created.
* @param createdBy
* The unique identifier of the user who created this group.
*/
case class Group(
id: Group.Id,
slug: Slug,
createdAt: CreatedAt
createdAt: CreatedAt,
createdBy: CreatedBy
)
object Group:

View file

@ -1,44 +0,0 @@
package gs.smolban.model
import java.time.Instant
/** Enumeration that describes the status of a [[Ticket]] in Smolban. Smolban
* does not yet support custom status/workflow.
*/
sealed trait Status:
def name: String
def enteredAt: Instant
object Status:
/** This ticket is new, and ready to be started. New tickets may be put into
* progress or canceled.
*/
case class Ready(enteredAt: Instant) extends Status:
val name: String = "ready"
/** This ticket is being worked on actively. In progress tickets can be
* paused, completed, or canceled.
*/
case class InProgress(enteredAt: Instant) extends Status:
val name: String = "in_progress"
/** This ticket was being worked on, but was temporarily stopped. Paused
* tickets may be put into progress or canceled.
*/
case class Paused(enteredAt: Instant) extends Status:
val name: String = "paused"
/** This ticket was driven to completion. The work is done. Once in this
* state, the status may no longer change.
*/
case class Complete(enteredAt: Instant) extends Status:
val name: String = "complete"
/** This ticket was canceled for some reason. Once in this state, the status
* may no longer change.
*/
case class Canceled(enteredAt: Instant) extends Status:
val name: String = "canceled"
end Status

View file

@ -1,6 +1,8 @@
package gs.smolban.model
import cats.Show
import gs.smolban.model.users.User
import java.time.Instant
/** Tickets represent some tracked work.
*
@ -19,9 +21,11 @@ import cats.Show
* @param tags
* List of [[Tag]] applied to this ticket.
* @param status
* Current [[Status]] of this ticket.
* Current [[Ticket.Status]] of this ticket.
* @param statusHistory
* Linear history of this ticket in terms of status changes.
* @param assignee
* If set, this ticket is assigned to a specific user.
*/
case class Ticket(
id: Ticket.Id,
@ -31,8 +35,9 @@ case class Ticket(
title: String,
description: String,
tags: List[Tag],
status: Status,
statusHistory: List[Status]
status: Ticket.Status,
statusHistory: List[(Ticket.Status, Instant)],
assignee: Option[User.Id]
)
object Ticket:
@ -68,4 +73,47 @@ object Ticket:
end Id
/** Enumeration that describes the status of a [[Ticket]] in Smolban. Smolban
* does not yet support custom status/workflow.
*/
sealed abstract class Status(val name: String)
object Status:
given CanEqual[Status, Status] = CanEqual.derived
given Show[Status] = _.name
/** This ticket is new, and ready to be started. New tickets may be put into
* progress or canceled.
*/
case object Ready extends Status("ready")
/** This ticket is being worked on actively. In progress tickets can be
* paused, completed, or canceled.
*/
case object InProgress extends Status("in_progress")
/** This ticket was being worked on, but was temporarily stopped. Paused
* tickets may be put into progress or canceled.
*/
case object Paused extends Status("paused")
/** This ticket was driven to completion. The work is done. Once in this
* state, the status may no longer change.
*/
case object Complete extends Status("complete")
/** This ticket was canceled for some reason. Once in this state, the status
* may no longer change.
*/
case object Canceled extends Status("canceled")
val All: List[Status] = List(Ready, InProgress, Paused, Complete, Canceled)
def parse(candidate: String): Option[Status] =
All.find(_.name.equalsIgnoreCase(candidate))
end Status
end Ticket

View file

@ -12,17 +12,20 @@ import gs.uuid.v0.UUID
* The instant at which this user was created.
* @param username
* The (unique) [[Username]] of this user.
* @param userType
* The [[UserType]] of this user.
* @param designation
* The [[User.Designation]] of this user.
* @param roles
* List of [[Role]] assigned to this user.
* @param status
* The current [[User.Status]] of this user.
*/
case class User(
id: User.Id,
createdAt: CreatedAt,
username: Username,
userType: UserType,
roles: List[Role]
designation: User.Designation,
roles: List[Role],
status: User.Status
)
object User:
@ -58,4 +61,36 @@ object User:
end Id
/** Enumeration that describes the designation of a [[User]].
*/
sealed abstract class Designation(val name: String)
object Designation:
/** Regular users are typically human, and are expected to be using the Web
* UI and _possibly_ APIs.
*/
case object Regular extends Designation("regular")
/** Service users are intended for use by API-consuming services. They are
* not suitable for human/UI interactive use.
*/
case object Service extends Designation("service")
end Designation
/** Enumeration that describes the status of a [[User]] in Smolban.
*/
sealed abstract class Status(val name: String)
object Status:
given CanEqual[Status, Status] = CanEqual.derived
given Show[Status] = _.name
case object Active extends Status("active")
case object Suspended extends Status("suspended")
case object Off extends Status("off")
end User

View file

@ -1,19 +0,0 @@
package gs.smolban.model.users
/** Enumeration that describes the type of a [[User]].
*/
sealed abstract class UserType(val name: String)
object UserType:
/** Regular users are typically human, and are expected to be using the Web UI
* and _possibly_ APIs.
*/
case object Regular extends UserType("regular")
/** Service users are intended for use by API-consuming services. They are not
* suitable for human/UI interactive use.
*/
case object Service extends UserType("service")
end UserType