Skip to content

Instantly share code, notes, and snippets.

@wpoosanguansit
wpoosanguansit / Doobie Nested Queries
Last active February 17, 2022 15:41
Doobie Nested Queries
selectEventOnlyFutureTarget(id: String, guid: String, timestamp: LocalDateTime, limit: Int): Process[ConnectionIO, Target]
selectEventOnlyPastTarget(id: String, guid: String, timestamp: LocalDateTime, limit: Int): Process[ConnectionIO, Target]
getSubTarget1(id: String, guid: String): ConnectionIO[List[SubTarget1]]
getSubTarget2(ooid: String, guid: String): Process[ConnectionIO, SubTarget2]
getSubTarget3(ooid: String, guid: String): Process[ConnectionIO, SubTarget3]
val statements = List[ConnectionIO[List[Target]]](
selectEventOnlyFutureTarget(id, guid, timestamp, futureLimit).list,
selectEventOnlyPastTarget(id, guid, timestamp, pastLimit).list
object DynamicQuery {
val connection = DriverManager.getConnection(url, properties)
def dynamicQuery(queries: Seq[(String, String, Int, String)]): Map[(String, String, String, Int), (String, Boolean)] = {
val variables = scala.collection.mutable.Map[(String, String, String, Int), (String, Boolean)]()
queries.foreach { case (objectName, typeCode, index, query) =>
val stmt = connection.createStatement
@wpoosanguansit
wpoosanguansit / Scala QuadTree
Last active December 21, 2015 01:19
Scala QuadTrie for Android point of interest clustering.
package com.utility
/*
Copyright (c) 2012 Watt P.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is