-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beb2742
commit 937aee7
Showing
83 changed files
with
3,388 additions
and
269 deletions.
There are no files selected for viewing
Submodule ergoMixFront
updated
16 files
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dao | ||
|
||
import models.Models.{CovertAsset, MixCovertRequest} | ||
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider} | ||
import slick.jdbc.JdbcProfile | ||
|
||
import javax.inject.{Inject, Singleton} | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
@Singleton() | ||
class CovertsDAO @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)(implicit executionContext: ExecutionContext) | ||
extends CovertAddressesComponent with CovertDefaultsComponent with MixingCovertRequestComponent | ||
with HasDatabaseConfigProvider[JdbcProfile] { | ||
|
||
import profile.api._ | ||
|
||
val covertAddresses = TableQuery[CovertAddressesTable] | ||
val covertAssets = TableQuery[CovertDefaultsTable] | ||
val covertRequests = TableQuery[MixCovertRequestTable] | ||
|
||
/** | ||
* selects unspent and spent deposits by address | ||
* | ||
* @param address String | ||
*/ | ||
def createCovert(req: MixCovertRequest, addresses: Seq[(String, String)], asset: CovertAsset): Future[Unit] = { | ||
val query = for { | ||
_ <- DBIO.seq(covertRequests += req, covertAddresses ++= addresses, covertAssets += asset).transactionally | ||
} yield { } | ||
db.run(query) | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package dao | ||
|
||
import javax.inject.{Inject, Singleton} | ||
import models.Models.HopMix | ||
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider} | ||
import slick.jdbc.JdbcProfile | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
trait HopMixComponent { | ||
self: HasDatabaseConfigProvider[JdbcProfile] => | ||
|
||
import profile.api._ | ||
|
||
class HopMixTable(tag: Tag) extends Table[HopMix](tag, "HOP_MIX") { | ||
def id = column[String]("MIX_ID") | ||
|
||
def round = column[Int]("ROUND") | ||
|
||
def createdTime = column[Long]("CREATED_TIME") | ||
|
||
def boxId = column[String]("BOX_ID") | ||
|
||
def * = (id, round, createdTime, boxId) <> (HopMix.tupled, HopMix.unapply) | ||
|
||
def pk = primaryKey("pk_HOP_MIX", (id, round)) | ||
} | ||
|
||
} | ||
|
||
@Singleton() | ||
class HopMixDAO @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)(implicit executionContext: ExecutionContext) | ||
extends HopMixComponent | ||
with HasDatabaseConfigProvider[JdbcProfile] { | ||
|
||
import profile.api._ | ||
|
||
val hopMixes = TableQuery[HopMixTable] | ||
|
||
/** | ||
* inserts a hop into table | ||
* | ||
* @param hop HopMix | ||
*/ | ||
def insert(hop: HopMix): Future[Unit] = db.run(hopMixes += hop).map(_ => ()) | ||
|
||
/** | ||
* returns all hops | ||
* | ||
*/ | ||
def all: Future[Seq[HopMix]] = db.run(hopMixes.result) | ||
|
||
/** | ||
* deletes all of hops | ||
* | ||
*/ | ||
def clear: Future[Unit] = db.run(hopMixes.delete).map(_ => ()) | ||
|
||
/** | ||
* deletes future hops by mixId | ||
* | ||
* @param mixId String | ||
* @param round Int | ||
*/ | ||
def deleteFutureRounds(mixId: String, round: Int): Future[Unit] = db.run(hopMixes | ||
.filter(hop => hop.id === mixId && hop.round > round).delete).map(_ => ()) | ||
|
||
/** | ||
* updates hop by id | ||
* | ||
* @param hopMix HopMix | ||
*/ | ||
def updateById(hopMix: HopMix): Future[Unit] = db.run(DBIO.seq( | ||
hopMixes.filter(hop => hop.id === hopMix.mixId && hop.round === hopMix.round).delete, | ||
hopMixes += hopMix | ||
)) | ||
|
||
/** | ||
* returns last hop round of mixId | ||
* | ||
* @param mixId String | ||
*/ | ||
def getHopRound(mixId: String): Future[Option[Int]] = db.run(hopMixes | ||
.filter(hop => hop.id === mixId) | ||
.groupBy(hop => hop.id) | ||
.map{ case (id, group) => group.map(_.round).max.get } | ||
.result.headOption | ||
) | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.