Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Refactor boilerplate code in Search API #204

Merged
merged 5 commits into from
Jun 7, 2018

Conversation

arturalbov
Copy link
Contributor

Refactor boilerplate code in Search API

@arturalbov arturalbov requested a review from hleb-albau June 6, 2018 13:03
@coveralls
Copy link

coveralls commented Jun 6, 2018

return mappingContext
}

fun getKeyspaceSession(cluster: Cluster,
Copy link
Contributor

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}"
Copy link
Contributor

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<*>>
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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>(
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@arturalbov arturalbov merged commit 4efad3c into master Jun 7, 2018
@arturalbov arturalbov deleted the 114_refactor_boilerplate_code_search_api branch June 7, 2018 11:56
@arturalbov
Copy link
Contributor Author

Closes #114

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants