From 8f014c86944e17f33fcc2b91080012b03b00c8ab Mon Sep 17 00:00:00 2001 From: Richard Rodgers Date: Thu, 16 Jul 2015 10:34:21 -0400 Subject: [PATCH 1/2] Match new topics to subscriber interests Fixes #288 --- app/workers/Cataloger.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/workers/Cataloger.scala b/app/workers/Cataloger.scala index fe3d27d..4d67862 100644 --- a/app/workers/Cataloger.scala +++ b/app/workers/Cataloger.scala @@ -42,6 +42,8 @@ class Cataloger(resmap: ResourceMap, content: StoredContent) { var infoCache = Map[String, Seq[String]]() // count of added topics var addedTopics = 0 + // newly created topics + var newTopics: List[Topic] = List() def topics(scheme: Scheme, item: Item) = { // where in the item's resource map is data for this scheme? Skip if unmapped @@ -142,6 +144,7 @@ class Cataloger(resmap: ResourceMap, content: StoredContent) { Topic.create(scheme.id, tag, title) val topic = Topic.forSchemeAndTag(scheme.tag, tag).get Indexer.index(topic) + newTopics :+ topic topic } @@ -306,6 +309,8 @@ object Cataloger { // finally, are there any subscriptions to fulfill? Conveyor.newItem(item) //item.changeState("cataloged") + // let Conveyor know about any new topics also + cataloger.newTopics.foreach(t => Conveyor.newTopic(t)) } def testExpression(expr: String, exprType: String, source: String) = { From ecd152d1ce08e0593b2dff13a1d80ec266a74ff7 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Thu, 16 Jul 2015 14:06:44 -0400 Subject: [PATCH 2/2] Set result of immutable list operation back to variable the `:+` syntax returns a new list and does not modify the original immutable list. This minor change accommodates that. --- app/workers/Cataloger.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/Cataloger.scala b/app/workers/Cataloger.scala index 4d67862..cae76df 100644 --- a/app/workers/Cataloger.scala +++ b/app/workers/Cataloger.scala @@ -144,7 +144,7 @@ class Cataloger(resmap: ResourceMap, content: StoredContent) { Topic.create(scheme.id, tag, title) val topic = Topic.forSchemeAndTag(scheme.tag, tag).get Indexer.index(topic) - newTopics :+ topic + newTopics = newTopics :+ topic topic }