Skip to content

Commit

Permalink
Merge pull request #354 from tumblr/bhaskar-adding-stats
Browse files Browse the repository at this point in the history
Adding additional stats.
  • Loading branch information
yl3w committed Aug 5, 2015
2 parents 5ef1769 + f8879cf commit b3b816a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/collins/models/Asset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ object Asset extends Schema with AnormAdapter[Asset] with AssetKeys {
// Loads assets from cache, then database if not available in cache.
// Asset are loaded from database using 'in' clause, and are added to cache
// Returns assets in the order requested, i.e. tag order in params
def findByTags(tags: Seq[String]) = {
def findByTags(tags: Seq[String]) = Stats.time("Asset.findByTags") {
val ltags = tags.map { _.toLowerCase }
val assetOpts = ltags.map { tag => tag -> Cache.get[Option[Asset]](findByTagKey(tag)) }.toMap
val loadedAssets = inTransaction { from(tableDef)(s =>
Expand Down
9 changes: 7 additions & 2 deletions app/collins/solr/CollinsSearchQuery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.apache.solr.common.SolrDocument

import play.api.Logger

import collins.util.Stats

import collins.models.Asset
import collins.models.AssetLog
import collins.models.shared.Page
Expand Down Expand Up @@ -48,8 +50,11 @@ abstract class CollinsSearchQuery[T](docType: SolrDocType, query: TypedSolrExpre
Left("Solr is not initialized!")
}

def getPage[V](f: Seq[T] => Seq[V] ): Either[String, Page[V]] = getResults().right.map{case (results, total) =>
Page(f(results), page.page, page.page * page.size, total)
def getPage[V](f: Seq[T] => Seq[V]): Either[String, Page[V]] = Stats.time(f"Solr.find-pgs-${page.size}%d") {
getResults().right.map {
case (results, total) =>
Page(f(results), page.page, page.page * page.size, total)
}
}

protected def getSortDirection() = {
Expand Down

0 comments on commit b3b816a

Please sign in to comment.