PageRenderTime 31ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/scala/travel/loader/MongoWriter.scala

https://github.com/tackley/travel-map
Scala | 27 lines | 20 code | 4 blank | 3 comment | 0 complexity | a0e0db5ee16b7708e2ba319e78cd9829 MD5 | raw file
  1. package travel.loader
  2. import com.mongodb.casbah.Imports._
  3. import com.mongodb.casbah.commons.MongoDBObject
  4. import org.joda.time.DateTime
  5. import com.weiglewilczek.slf4s.Logging
  6. object MongoWriter extends Logging {
  7. def write(items: List[ContentItem]) {
  8. logger.info("Writing %d items to mongo..." format items.size)
  9. items foreach ContentItem.save
  10. }
  11. def mostRecentLastModified = {
  12. ContentItem.find(MongoDBObject())
  13. .sort(orderBy = MongoDBObject("lastModified" -> -1))
  14. .limit(1)
  15. .toList
  16. .headOption
  17. .map(_.lastModified)
  18. // why this magic date?
  19. // from looking at the content api data, nothing is geotagged before this date.
  20. // presumably the feature did not exist.
  21. .getOrElse(new DateTime(2008, 10, 1, 0, 0, 0, 0))
  22. }
  23. }