This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.megafarad.omoiomoi.controllers | |
import com.megafarad.omoiomoi.auth.AuthAction | |
import com.megafarad.omoiomoi.dao.MeetingDAO | |
import com.megafarad.omoiomoi.model.Meeting._ | |
import com.megafarad.omoiomoi.model.MeetingEvent._ | |
import com.megafarad.omoiomoi.model.{Meeting, MeetingEvent, Page, SearchResult} | |
import play.api._ | |
import play.api.cache.AsyncCacheApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.megafarad.omoiomoi.binders | |
import play.api.mvc.QueryStringBindable | |
import java.time.format.DateTimeParseException | |
import java.time.zone.ZoneRulesException | |
import java.time.{LocalDate, ZoneId} | |
object CustomBinders { | |
implicit def localDateBinder(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[LocalDate] = new QueryStringBindable[LocalDate] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- !Ups | |
CREATE SCHEMA app; | |
CREATE TABLE app.document ( | |
id BIGSERIAL NOT NULL PRIMARY KEY, | |
content TEXT, | |
search_field tsvector | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
import utils.StringUtils | |
case class Document(id: Option[Long], content: String) { | |
lazy val abbreviatedContent: String = StringUtils.ellipses(content, 100) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
case class Page[T](items: Seq[T], page: Int, offset: Int, total: Long, totalPageCount: Long) { | |
lazy val prev: Option[Int] = Option(page - 1).filter(_ >= 0) | |
lazy val next: Option[Int] = Option(page + 1).filter(_ => (offset + items.size) < total) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
case class SearchResult(highlights: String, rank: Float, documentId: Long) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.daos | |
import com.github.tminglei.slickpg._ | |
trait MyPostgresProfile extends ExPostgresProfile | |
with PgArraySupport | |
with PgDate2Support | |
with PgRangeSupport | |
with PgHStoreSupport | |
with PgSearchSupport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.daos | |
import MyPostgresProfile.api._ | |
import com.github.tminglei.slickpg.TsVector | |
import models.Document | |
import slick.lifted.ProvenShape | |
trait TableDefinitions { | |
class DocumentTable(tag: Tag) extends Table[Document](tag, Some("app"), "document") { | |
def id = column[Long]("id", O.PrimaryKey, O.AutoInc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.daos | |
import models.{Document, Page, SearchResult} | |
import MyPostgresProfile.api._ | |
import play.api.Logging | |
import play.api.db.slick.DatabaseConfigProvider | |
import javax.inject.Inject | |
import scala.concurrent.{ExecutionContext, Future} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.services | |
import models.{Document, Page, SearchResult} | |
import models.daos.DocumentDAO | |
import javax.inject.Inject | |
import scala.concurrent.{ExecutionContext, Future} | |
class DocumentServiceImpl @Inject() (documentDAO: DocumentDAO)(implicit ec: ExecutionContext) extends DocumentService { |