Commits

rowyn  committed d33722d

Fixed dateFiled bug. Restricted queries to cases where we have the reporter.

  • Participants
  • Parent commits 8e5e38b

Comments (0)

Files changed (2)

File alert/citations/find_citations.py

     '''Given a list of words and the index of a federal reporter, look before and after
     for volume and page number.  If found, construct and return a Citation object.'''
     reporter = words[reporter_index]
+    # Get rid of extra space so that we only have one version to check
+    if reporter == 'U. S.':
+        reporter = 'U.S.'
     if words[reporter_index - 1].isdigit():
         volume = int(words[reporter_index - 1])
     else: # No volume, therefore not a valid citation

File alert/citations/match_citations.py

 
 DEBUG = True
 
+# Reporters currently covered in the CourtListener database
+CL_REPORTERS = ['F.2d', 'F.3d', 'U.S.']
+
 REPORTER_DATES = {'F.': (1880, 1924),
                   'F.2d': (1924, 1993),
                   'F.3d': (1999, date.today().year),
     return results
 
 def match_citation(citation, citing_doc):
+    # First, check and see whether we even have documents from this reporter
+    if not citation.reporter in CL_REPORTERS:
+        return [], True
     # TODO: Create shared solr connection to use across multiple citations/documents
     conn = sunburnt.SolrInterface(settings.SOLR_URL, mode='r')
     main_params = {}
     if citation.year:
         start_year = end_year = citation.year
     else:
-        end_year = citing_doc.dateFiled.year
         start_year = 1754 # Earliest case in the db
+        end_year = date.today().year
         if citation.reporter in REPORTER_DATES:
-            reporter_start, reporter_end = REPORTER_DATES[citation.reporter]
-            start_year = max(start_year, reporter_start)
-            end_year = min(end_year, reporter_end)
+            start_year, end_year = REPORTER_DATES[citation.reporter]
+        if citing_doc.dateFiled:
+            end_year = min(end_year, citing_doc.dateFiled.year)
     date_param = 'dateFiled:%s' % build_date_range(start_year, end_year)
     main_params['fq'].append(date_param)
     if not citation.court and citation.reporter in ["U.S.", "U. S."]: