diff --git a/coverage/.last_run.json b/coverage/.last_run.json index 9880d09..ca574ee 100644 --- a/coverage/.last_run.json +++ b/coverage/.last_run.json @@ -1,5 +1,5 @@ { "result": { - "line": 83.76 + "line": 81.33 } } diff --git a/coverage/.resultset.json b/coverage/.resultset.json index f19890a..92b14d1 100644 --- a/coverage/.resultset.json +++ b/coverage/.resultset.json @@ -134,6 +134,7 @@ null, null, null, + null, 2, null, null, @@ -161,7 +162,7 @@ 1, null, null, - 0, + 132, null, null, 1, @@ -3005,15 +3006,6 @@ null, null, 1, - 15, - null, - 14, - 14, - null, - 32, - null, - null, - 1, 2, null, 1, @@ -3027,12 +3019,33 @@ null, null, 1, + 15, + null, + 14, + 14, + null, + 14, + null, + null, + 18, + null, + null, + 1, 4, 16, 4, null, null, 1, + 3, + null, + 3, + 3, + null, + 9, + null, + null, + 1, 54, null, null @@ -3369,6 +3382,13 @@ 0, null, 0, + 4, + 0, + 0, + 0, + null, + null, + 0, null, 4, null, @@ -3376,6 +3396,104 @@ null, null, 1, + null, + null, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + 0, + null, + null, + null, + 1, 3, 2, null, @@ -3396,7 +3514,6 @@ null, null, null, - null, 0, 0, 0, @@ -3421,6 +3538,14 @@ null, null, 0, + 0, + null, + null, + null, + null, + null, + null, + 0, null, null, 1, @@ -3431,6 +3556,7 @@ null, null, 1, + null, 0, null, 0, @@ -3447,6 +3573,55 @@ null, 1, null, + 9, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + null, 1, null, 0, @@ -3713,6 +3888,6 @@ ] } }, - "timestamp": 1725878428 + "timestamp": 1726139945 } } diff --git a/coverage/index.html b/coverage/index.html index 531d1e9..5da11f3 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -14,7 +14,7 @@
month: 'Date'
+ month: 'Date',
}
+ session: 'Session'
@@ -3595,12 +3595,23 @@ }
+
+
+
+
def facets
+ def query_time
return [] unless search
+ return unless search&.dig(:data, 'responseHeader', 'QTime')
facet_field_data = search.dig(:data, 'facets')
+ time = search&.dig(:data, 'responseHeader', 'QTime')
return [] if facet_field_data.blank?
+ return if time.blank?
facet_field_data.except("count").map { |k, v| { field_name: k, facets: sort_facets(v['buckets']) } }
+ time.to_f / 1000
def query_time
+ def filter
return unless search&.dig(:data, 'responseHeader', 'QTime')
+ search.dig(:search_parameters, :filter)
+ end
time = search&.dig(:data, 'responseHeader', 'QTime')
+
return if time.blank?
+ def facets
+
+
+
+ return [] unless search
time.to_f / 1000
+ facet_field_data = search.dig(:data, 'facets')
end
+ return [] if facet_field_data.blank?
def filter
+ facet_field_data.slice("type_sesrollup", "publisher_ses", "legislature_ses", "date_dt", "department_ses",
search.dig(:search_parameters, :filter)
+ "member_ses", "tablingMember_ses", "askingMember_ses", "leadMember_ses",
"answeringMember_ses", "legislativeStage_ses", "legislationTitle_ses", "subject_ses",
+ "topic_ses", "year").map { |k, v| { field_name: k, facets: sort_facets(v['buckets']) } }
+ def session_facets
+ return [] unless search
+
+ facet_field_data = search.dig(:data, 'facets')
+ return [] if facet_field_data.blank?
+
+ facet_field_data.select { |field| field.split('_').first == "session" }
+ end
+
+ 'session_t',
+ 'legislature_ses',
else
+ elsif field_name == "session"
"{!tag=#{field_name}}#{field_name}:(#{values.join(" ")})"
+ ranges = []
end
+ values.each do |value|
end
+ ranges << session_range_lookup(value)
end
+ end
@@ -37150,40 +37293,40 @@
+ # "{!tag=session_t}date_dt:(#{ranges.join(" OR ")})"
def sort
+ "{!tag=session_t}(date_dt:(#{ranges.join(" OR ")}) OR session_t:(#{values.join(" OR ")}))"
return 'date_dt desc' if sort_by == "date_desc"
+ else
return 'date_dt asc' if sort_by == "date_asc"
+ "{!tag=#{field_name}}#{field_name}:(#{values.join(" ")})"
+ end
'date_dt desc'
+ end
def facet_hash
+ def session_range_lookup(value)
@@ -37249,7 +37392,7 @@ # hash with keys as names of facets
+ # TODO: this will likely become a Session model, with persistance and admin features to set the names
@@ -37260,18 +37403,18 @@
+ # as well as 'from' and 'to' dates.
ret = {}
+
SolrSearch.facet_fields.each do |field_name|
+ case value
ret[field_name] = {
+ when '2024-25'
"type" => facet_type(field_name),
+ '[2024-05-25T00:00:00Z TO *]'
"field" => field_name,
+ when '2023-24'
"limit" => facet_limit(field_name),
+ '[2023-10-27T00:00:00Z TO 2024-05-24T23:59:00Z]'
"missing" => true,
+ when '2022-23'
"mincount" => facet_mincount(field_name),
+ '[2022-04-29T00:00:00Z TO 2023-10-26T23:59:59Z]'
"domain" => { excludeTags: field_name }
+ when '2021-22'
}
+ '[2021-05-11T00:00:00Z TO 2022-04-28T23:59:59Z]'
end
+ when '2019-21'
+ '[2019-12-17T00:00:00Z TO 2021-05-10T23:59:59Z]'
if filter&.dig(:year).present?
+ when '2019-19'
year = filter.dig(:year).first
+ '[2019-10-14T01:00:00Z TO 2019-11-06T00:01:00Z]'
ret['month'] = {
+ when '2017-19'
"type": "range",
+ '[2017-05-03T00:00:00Z TO 2019-10-13T23:59:59Z]'
"field": "date_dt",
+ when '2016-17'
"start": "#{year}-01-01T00:00:00Z",
+ '[2016-05-13T00:00:00Z TO 2017-05-02T23:59:59Z]'
"end": "#{year}-12-31T23:59:59Z",
+ when '2015-16'
"gap": "+1MONTH",
+ '[2015-04-01T00:00:00Z TO 2016-05-12T23:59:59Z]'
"mincount": 0,
+ when '2014-15'
"domain": { excludeTags: 'month' }
+ '[2014-05-14T23:00:00Z TO 2015-03-30T23:59:59Z]'
}
+ when '2013-14'
else
+ '[2013-04-25T23:00:00Z TO 2014-06-03T22:59:59Z]'
ret['year'] = {
+ when '2012-13'
"type": "range",
+ '[2012-05-08T23:00:00Z TO 2013-04-25T22:59:59Z]'
"field": "date_dt",
+ when '2010-12'
"start": "1500-01-01T00:00:00Z",
+ '[2010-05-17T23:00:00Z TO 2012-05-08T22:59:59Z]'
"end": "#{Date.today.strftime("%Y-%m-%d")}T23:59:59Z",
+ when '2009-10'
"gap": "+1YEAR",
+ '[2009-11-18T00:00:00Z TO 2010-05-17T22:59:59Z]'
"mincount": 1,
+ when '2008-09'
"limit": 100
+ '[2008-12-03T00:00:00Z TO 2009-11-17T23:59:59Z]'
}
+ when '2007-08'
end
+ '[2007-11-06T00:00:00Z TO 2008-12-02T23:59:59Z]'
+ when '2006-07'
@@ -37656,7 +37799,7 @@ ret.to_json
+ '[2006-11-15T00:00:00Z TO 2007-11-05T23:59:59Z]'
@@ -37667,29 +37810,29 @@ end
+ when '2005-06'
+ '[2005-05-10T23:00:00Z TO 2006-11-14T23:59:59Z]'
def facet_type(field_name)
+ when '2004-05'
arr = []
+ '[2004-11-23T00:00:00Z TO 2005-05-10T22:59:59Z]'
return "terms" unless arr.include?(field_name)
+ when '2003-04'
+ '[2003-11-26T00:00:00Z TO 2004-11-22T23:59:59Z]'
" " # replacement type
+ when '2002-03'
end
+ '[2002-11-10T00:00:00Z TO 2003-11-25T23:59:59Z]'
+ when '2001-02'
def facet_limit(field_name)
+ '[2001-06-12T23:00:00Z TO 2002-11-09T23:59:59Z]'
type_facet_names = ["type_sesrollup"]
+ when '2000-01'
+ '[2000-12-06T00:00:00Z TO 2001-06-12T22:59:59Z]'
return 80 unless type_facet_names.include?(field_name)
+ when '1999-00'
+ '[1999-11-17T00:00:00Z TO 2000-12-05T23:59:59Z]'
-1
+ when '1998-99'
end
+ '[1998-11-24T00:00:00Z TO 1999-11-16T23:59:59Z]'
+ when '1997-98'
def facet_mincount(field_name)
+ '[1997-05-06T23:00:00Z TO 1998-11-23T23:59:59Z]'
arr = []
+ when '1996-97'
return 1 unless arr.include?(field_name)
+ '[1996-10-22T23:00:00Z TO 1997-05-06T22:59:59Z]'
@@ -37887,7 +38030,7 @@
+ when '1995-96'
@@ -37898,7 +38041,7 @@ 0 # replacement mincount
+ '[1995-11-15T00:00:00Z TO 1996-10-22T22:59:59Z]'
@@ -37909,84 +38052,84 @@ end
+ when '1994-95'
+ '[1994-11-16T00:00:00Z TO 1995-11-14T23:59:59Z]'
private
+ when '1993-94'
+ '[1993-11-18T00:00:00Z TO 1994-11-15T23:59:59Z]'
def search_params
+ when '1992-93'
{
+ '[1992-04-26T23:00:00Z TO 1993-11-17T23:59:59Z]'
q: search_query,
+ when '1991-92'
'q.op': 'AND',
+ '[1991-10-31T00:00:00Z TO 1992-04-26T22:59:59Z]'
fq: search_filter,
+ when '1990-91'
start: start,
+ '[1990-11-07T00:00:00Z TO 1991-10-30T23:59:59Z]'
rows: rows,
+ when '1989-90'
sort: sort,
+ '[1989-11-21T00:00:00Z TO 1990-11-06T23:59:59Z]'
'json.facet': facet_hash
+ when '1988-89'
}
+ '[1988-11-22T00:00:00Z TO 1989-11-20T23:59:59Z]'
when '1987-88'
+
+
+
+ '[1987-06-16T23:00:00Z TO 1988-11-21T23:59:59Z]'
+ when '1986-87'
+ '[1986-11-12T00:00:00Z TO 1987-06-16T22:59:59Z]'
+ when '1985-86'
+ '[1985-11-05T00:00:00Z TO 1986-11-11T23:59:59Z]'
+ when '1984-85'
+ '[1984-11-06T00:00:00Z TO 1985-11-04T23:59:59Z]'
+ when '1983-84'
+ '[1983-06-14T23:00:00Z TO 1984-11-05T23:59:59Z]'
+ when '1982-83'
+ '[1982-11-03T00:00:00Z TO 1983-06-14T22:59:59Z]'
+ when '1981-82'
+ '[1981-11-04T00:00:00Z TO 1982-11-02T23:59:59Z]'
+ when '1980-81'
+ '[1980-11-20T00:00:00Z TO 1981-11-03T23:59:59Z]'
+ when '1979-80'
+ '[1979-05-08T23:00:00Z TO 1980-11-19T23:59:59Z]'
+ else
+ ''
+ end
+ end
+
+ def sort
+ return 'date_dt desc' if sort_by == "date_desc"
+ return 'date_dt asc' if sort_by == "date_asc"
+
+ 'date_dt desc'
+ end
+ def facet_hash
+ # hash with keys as names of facets
+
+ ret = {}
+ SolrSearch.facet_fields.each do |field_name|
+ ret[field_name] = {
+ "type" => facet_type(field_name),
+ "field" => field_name,
+ "limit" => facet_limit(field_name),
+ "mincount" => facet_mincount(field_name),
+ "domain" => { excludeTags: field_name }
+ }
+ end
+
+ if filter&.dig(:year).present?
+ year = filter.dig(:year).first
+ ret['month'] = {
+ "type": "range",
+ "field": "date_dt",
+ "start": "#{year}-01-01T00:00:00Z",
+ "end": "#{year}-12-31T23:59:59Z",
+ "gap": "+1MONTH",
+ "mincount": 0,
+ "domain": { excludeTags: 'month' }
+ }
+ else
+ ret['year'] = {
+ "type": "range",
+ "field": "date_dt",
+ "start": "1500-01-01T00:00:00Z",
+ "end": "#{Date.today.strftime("%Y-%m-%d")}T23:59:59Z",
+ "gap": "+1YEAR",
+ "mincount": 1,
+ "limit": 100
+ }
+ end
+
+ SolrSearch.sessions.each do |session|
+ ret["session_#{session}"] = {
+ "type": "query",
+ "q": "(session_t:#{session} OR date_dt:#{session_range_lookup(session)})",
+ "domain": { excludeTags: 'session_t' }
+ }
+ end
+
+ ret.to_json
+ end
+
+ def facet_type(field_name)
+ arr = []
+ return "terms" unless arr.include?(field_name)
+
+ " " # replacement type
+ end
+
+ def facet_limit(field_name)
+ # limit to 80 except for
+ facet_names = ["type_sesrollup"]
+
+ return 80 unless facet_names.include?(field_name)
+
+ -1
+ end
+
+ def facet_mincount(field_name)
+ arr = []
+ return 1 unless arr.include?(field_name)
+
+ 0 # replacement mincount
+ end
+
+ def self.sessions
+ [
+ '2024-25',
+ '2023-24',
+ '2022-23',
+ '2021-22',
+ '2019-21',
+ '2019-19',
+ '2017-19',
+ '2016-17',
+ '2015-16',
+ '2014-15',
+ '2013-14',
+ '2012-13',
+ '2010-12',
+ '2009-10',
+ '2008-09',
+ '2007-08',
+ '2006-07',
+ '2005-06',
+ '2004-05',
+ '2003-04',
+ '2002-03',
+ '2001-02',
+ '2000-01',
+ '1999-00',
+ '1998-99',
+ '1997-98',
+ '1996-97',
+ '1995-96',
+ '1994-95',
+ '1993-94',
+ '1992-93',
+ '1991-92',
+ '1990-91',
+ '1989-90',
+ '1988-89',
+ '1987-88',
+ '1986-87',
+ '1985-86',
+ '1984-85',
+ '1983-84',
+ '1982-83',
+ '1981-82',
+ '1980-81',
+ '1979-80'
+ ]
+ end
+
+ private
+
+ def search_params
+ {
+ q: search_query,
+ 'q.op': 'AND',
+ fq: search_filter,
+ start: start,
+ rows: rows,
+ sort: sort,
+ 'json.facet': facet_hash
+ }
+ end
+