Skip to content

Commit

Permalink
Using modified date for time of last change in browse silo page
Browse files Browse the repository at this point in the history
  • Loading branch information
Anusha Ranganathan committed Jun 12, 2012
1 parent 26e5506 commit 9fb9cb0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
15 changes: 10 additions & 5 deletions message_workers/solr_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def gather_document(silo_name, item):
redis_section = "redis"
worker_section = "worker_solr"
worker_number = sys.argv[1]
hours_before_commit = 1
if len(sys.argv) == 3:
if "redis_%s" % sys.argv[2] in c.sections():
redis_section = "redis_%s" % sys.argv[2]
Expand All @@ -98,14 +99,14 @@ def gather_document(silo_name, item):
solr = SolrConnection(c.get(worker_section, "solrurl"))

idletime = 2
commit_time = datetime.now() + timedelta(hours=1)
commit_time = datetime.now() + timedelta(hours=hours_before_commit)
toCommit = False
while(True):
sleep(idletime)

if datetime.now() > commit_time and toCommit:
solr.commit()
commit_time = datetime.now() + timedelta(hours=1)
commit_time = datetime.now() + timedelta(hours=hours_before_commit)
toCommit = False

line = rq.pop()
Expand All @@ -114,7 +115,7 @@ def gather_document(silo_name, item):
if toCommit:
solr.commit()
toCommit = False
commit_time = datetime.now() + timedelta(hours=1)
commit_time = datetime.now() + timedelta(hours=hours_before_commit)
continue

logger.debug("Got message %s" %str(line))
Expand Down Expand Up @@ -159,8 +160,12 @@ def gather_document(silo_name, item):
else:
silo_metadata = g.describe_silo(silo_name)
solr_doc = {'id':silo_name, 'silo':silo_name, 'type':'Silo', 'uuid':uuid4().hex}
solr_doc['title'] = silo_metadata['title']
solr_doc['description'] = silo_metadata['description']
solr_doc['title'] = ''
if 'title' in silo_metadata:
solr_doc['title'] = silo_metadata['title']
solr_doc['description'] = ''
if 'description' in silo_metadata:
solr_doc['description'] = silo_metadata['description']
solr.add(_commit=False, **solr_doc)
rq.task_complete()
elif msg['type'] == "d":
Expand Down
8 changes: 4 additions & 4 deletions rdfdatabank/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ def getSiloModifiedDate(silo_name):
solr_params['wt'] = 'json'
solr_params['start'] = 0
solr_params['rows'] = 1
solr_params['sort'] = "timestamp desc"
solr_params['fl'] = 'timestamp'
solr_params['sort'] = "modified desc"
solr_params['fl'] = 'modified'
solr_response = None
try:
solr_response = ag.solr.raw_query(**solr_params)
Expand All @@ -471,8 +471,8 @@ def getSiloModifiedDate(silo_name):
result = simplejson.loads(solr_response)
docs = result['response'].get('docs',None)
numFound = result['response'].get('numFound',None)
if docs and len(docs) > 0 and docs[0]:
dt = docs[0]['timestamp']
if docs and len(docs) > 0 and docs[0] and 'modified' in docs[0] and len(docs[0]['modified']) > 0:
dt = docs[0]['modified'][0]
else:
return ''
dt = formatDate(dt)
Expand Down
6 changes: 3 additions & 3 deletions rdfdatabank/templates/search_response_display.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
if 'type' in c.docs[doc_index] and c.docs[doc_index]['type']:
if not isinstance(c.docs[doc_index]['type'], list):
c.docs[doc_index]['type'] = [c.docs[doc_index]['type']]
for typ in c.docs[doc_index]['type']:
if typ.lower() == 'silo':
isSilo = True
for typ in c.docs[doc_index]['type']:
if typ.lower() == 'silo':
isSilo = True
%>
<h2 class="resultTitle">
% if isSilo == True:
Expand Down

0 comments on commit 9fb9cb0

Please sign in to comment.