-
Notifications
You must be signed in to change notification settings - Fork 14
Refactor boilerplate code in Search API #204
Conversation
…plate_code_search_api
return mappingContext | ||
} | ||
|
||
fun getKeyspaceSession(cluster: Cluster, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format?
* @param chainName chain name | ||
* @return search repository bean name | ||
*/ | ||
fun Class<*>.searchRepositoryBeanName(chainName: String) = "$chainName$REPOSITORY_NAME_DELIMITER${this.name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class<*> ? Is it possible to narrow down extension scope here?
@Autowired | ||
private lateinit var cluster: Cluster | ||
|
||
abstract fun repositoriesClasses(): List<Class<*>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class<*> ?
|
||
val blockNumber = request.pathVariable("blockNumber").toLong() | ||
val block = repository.findById(blockNumber) | ||
ServerResponse.ok().body(block, CqlBitcoinBlock::class.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add switchIfEmpty to all handlers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's out of the task scope. Will be implemented in #178
@Bean | ||
fun bitcoinContractItemHandler() = RepositoryItemRequestHandler( | ||
"/contract/{hash}", | ||
BitcoinContractSummaryRepository::class.java |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add ne more class, that takes 2 repos. It's okey.
Context lookup on each request is not we want.
import reactor.core.publisher.Mono | ||
|
||
|
||
class RepositoryItemRequestHandler<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
var slice = repository | ||
.findAllByMinerContractHash(hash.toSearchHashFormat(), CassandraPageRequest.first(pageSize)) | ||
|
||
for (i in 1..page) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe create common function for slice logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
…epositoryItemRequestHandler
Closes #114 |
Refactor boilerplate code in Search API