wikidata_position_history 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc98f35825bd450d052eaf0bbb84934db297933bce312b88fd8b545474b742bf
4
- data.tar.gz: 663abb5df3df62744eebbdeaea9ce2e63bf90aeff5335bf2406ae66306dd7608
3
+ metadata.gz: d5c2ddb3cb683a9510a52f729a3d49afbf98eddd62b45550fd836b69902dbdb9
4
+ data.tar.gz: e3c99ce76017a543011b0cd8f10f1d0858b27678a5f878a44076f74d82070c71
5
5
  SHA512:
6
- metadata.gz: d06f8f44b1b84107e9bed22f158479f2be66569511ee1f9dea33ceaa788a9cff118b15e3e0960723cc943a290f832c6442f5c8c8659fb275002449e57c90d285
7
- data.tar.gz: edae0f0fc3223778d655546c873792f81da0f514c50be44e27a192717df11c2672eedc251e2cf210ab4e623cdd0c5a232b6e65671c7cc9b2a356a1498ed3426f
6
+ metadata.gz: 1b97796606a4d6877705a058e17c4b1f112fc9c0621054a479492c3cc9cc5f20477fb9842c54641f6fe79d3f78e205f5433944e2ac598cfe162ca7a5ea155b9c
7
+ data.tar.gz: 0a5c78cb1e497494fd35102ace5edfac6942d1cbb958d74ec502b36ca70c06503045e7693a4c8423730f3c5d9c0ff371b18a1c504fc9cc8807afc5389e61670b
@@ -1,20 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ # [1.8.0] 2020-09-09
4
+
5
+ ## Enhancements
6
+
7
+ * If the very latest person we know of having held this position also
8
+ has a 'replaced by' qualifier, that’s a sign that the successor should
9
+ really also have a suitable P39, and actually appear here too. So we
10
+ want to display a warning in such cases. Likewise if the earliest person
11
+ we know if also has a 'replaces'
12
+
13
+ * This report is meant to be used with positions that are held by only a
14
+ single person at a time. Using it to produce a report of everyone who
15
+ has been, say, a Member of the UK Parliament, is the sort of thing that
16
+ will cause all manner of havoc, as it will try to display tens of
17
+ thousands of people, all of whom have overlaps with other members etc.
18
+ So we now sanity-check first of all that the position isn't legislative,
19
+ and produce a nice "Don’t do that!" message in such cases.
20
+
21
+ * It seems that the recent ability to handle dates that are only know at
22
+ decade-level precision isn’t actually enough, as we have some that we
23
+ only know at century-level precision! (For example, that the position of
24
+ Lord Chancellor of Ireland was created some time in the 12th Century.)
25
+ Such dates will now appear in a nicer format.
26
+
27
+ * Sometimes updating the table looks like something has changed, but
28
+ really the only difference is that a few of people who have no dates
29
+ are shuffled around a bit in the list. This is because we previously
30
+ only sorted by date order, so people with no dates were effectively in a
31
+ random order. Now we sort those people by ID too, which should minimise
32
+ the number of times an update will appear in your watchlist, only to
33
+ discover nothing significant actually happened.
34
+
3
35
  # [1.7.0] 2020-09-08
4
36
 
5
- # Enchancements
37
+ ## Enchancements
6
38
 
7
- * Yesterday’s future, when we said we'd do something a little better
39
+ * Yesterday’s future, when we said wed do something a little better
8
40
  with positions that have multiple inception or abolition dates, has
9
41
  arrived. Now we display all of them (with a warning), rather than just
10
42
  picking one semi-randomly.
11
43
 
12
- # Improvements
44
+ ## Improvements
13
45
 
14
46
  * A query like https://w.wiki/bVz is taking about 6 seconds to run.
15
47
  Changing that to https://w.wiki/bW3 drops that to about half a second.
16
48
  If you were to guess that the first has now been replaced by the
17
- second, you'd be entirely correct.
49
+ second, youd be entirely correct.
18
50
 
19
51
  # [1.6.0] 2020-09-07
20
52
 
@@ -22,7 +54,7 @@
22
54
 
23
55
  * If a position has an inception date and/or abolition date, those will
24
56
  now also be displayed. (If a position has more than one of either of
25
- those — which really shouldn't happen, but sometimes does — then the
57
+ those — which really shouldnt happen, but sometimes does — then the
26
58
  behaviour may not be particularly sensible. Later evolutions of this
27
59
  feature will hopefully handle that better.)
28
60
 
@@ -39,7 +71,7 @@
39
71
 
40
72
  * When showing the results for a position from long long ago (such as
41
73
  the High Kings of Ireland), display the dates as "862 – 879" not as
42
- "862879"
74
+ "08620879"
43
75
  * If we only know that someone took (or left) office sometime in a given
44
76
  decade (i.e. at date precision 8), display that as (say) "1930s"
45
77
 
@@ -54,7 +54,7 @@ module QueryService
54
54
  class WikidataDate
55
55
  include Comparable
56
56
 
57
- DATELEN = { '11' => 10, '10' => 7, '9' => 4, '8' => 4 }.freeze
57
+ DATELEN = { '11' => 10, '10' => 7, '9' => 4, '8' => 4, '7' => 2 }.freeze
58
58
 
59
59
  def initialize(str, precision)
60
60
  @str = str
@@ -105,6 +105,7 @@ module QueryService
105
105
  end
106
106
 
107
107
  def precisioned_string
108
+ return "#{truncated_string}. century" if precision == '7'
108
109
  return "#{truncated_string}s" if precision == '8'
109
110
 
110
111
  truncated_string
@@ -21,7 +21,7 @@ module WikidataPositionHistory
21
21
  OPTIONAL { ?posn pq:P1545 ?ordinal }
22
22
  OPTIONAL { ?posn pq:P5102 ?nature }
23
23
  }
24
- ORDER BY DESC(?start_date)
24
+ ORDER BY DESC(?start_date) ?item
25
25
  SPARQL
26
26
  end
27
27
  end
@@ -8,10 +8,12 @@ module WikidataPositionHistory
8
8
  <<~SPARQL
9
9
  # position-metadata
10
10
 
11
- SELECT DISTINCT ?item ?inception ?inception_precision ?abolition ?abolition_precision ?isPosition
11
+ SELECT DISTINCT ?item ?inception ?inception_precision ?abolition ?abolition_precision
12
+ ?isPosition ?isLegislator
12
13
  WHERE {
13
14
  VALUES ?item { wd:%s }
14
- BIND(EXISTS { wd:%s wdt:P279+ wd:Q4164871 } as ?isPosition)
15
+ BIND(EXISTS { wd:%s wdt:P279+ wd:Q4164871 } as ?isPosition)
16
+ BIND(EXISTS { wd:%s wdt:P279+ wd:Q4175034 } as ?isLegislator)
15
17
  OPTIONAL { ?item p:P571 [ a wikibase:BestRank ;
16
18
  psv:P571 [ wikibase:timeValue ?inception; wikibase:timePrecision ?inception_precision ]
17
19
  ] }
@@ -24,7 +26,7 @@ module WikidataPositionHistory
24
26
  end
25
27
 
26
28
  def sparql_args
27
- [itemid, itemid]
29
+ [itemid] * 3
28
30
  end
29
31
  end
30
32
  end
@@ -55,6 +57,10 @@ module WikidataPositionHistory
55
57
  row.dig(:isPosition, :value) == 'true'
56
58
  end
57
59
 
60
+ def legislator?
61
+ row.dig(:isLegislator, :value) == 'true'
62
+ end
63
+
58
64
  private
59
65
 
60
66
  attr_reader :row
@@ -25,11 +25,11 @@ module WikidataPositionHistory
25
25
  current.prev
26
26
  end
27
27
 
28
- def latest_holder?
28
+ def later_holder?
29
29
  !!later
30
30
  end
31
31
 
32
- def earliest_holder?
32
+ def earlier_holder?
33
33
  !!earlier
34
34
  end
35
35
  end
@@ -92,7 +92,7 @@ module WikidataPositionHistory
92
92
  # Does the 'replaces' match the previous item in the list?
93
93
  class WrongPredecessor < Check
94
94
  def problem?
95
- earliest_holder? && !!predecessor && (earlier.item != predecessor)
95
+ earlier_holder? && !!predecessor && (earlier.item != predecessor)
96
96
  end
97
97
 
98
98
  def headline
@@ -104,10 +104,25 @@ module WikidataPositionHistory
104
104
  end
105
105
  end
106
106
 
107
+ # Is there a 'replaces' but no previous item in the list?
108
+ class MissingPredecessor < Check
109
+ def problem?
110
+ predecessor && !earlier_holder?
111
+ end
112
+
113
+ def headline
114
+ 'Inconsistent predecessor'
115
+ end
116
+
117
+ def possible_explanation
118
+ "#{current.item} has a {{P|1365}} of #{predecessor}, but does not follow anyone here"
119
+ end
120
+ end
121
+
107
122
  # Does the 'replaced by' match the next item in the list?
108
123
  class WrongSuccessor < Check
109
124
  def problem?
110
- latest_holder? && !!successor && (later.item != successor)
125
+ later_holder? && !!successor && (later.item != successor)
111
126
  end
112
127
 
113
128
  def headline
@@ -119,6 +134,21 @@ module WikidataPositionHistory
119
134
  end
120
135
  end
121
136
 
137
+ # Is there a 'replaced by' but no next item in the list?
138
+ class MissingSuccessor < Check
139
+ def problem?
140
+ successor && !later_holder?
141
+ end
142
+
143
+ def headline
144
+ 'Inconsistent successor'
145
+ end
146
+
147
+ def possible_explanation
148
+ "#{current.item} has a {{P|1366}} of #{successor}, but is not followed by anyone here"
149
+ end
150
+ end
151
+
122
152
  # Does the end date overlap with the successor's start date?
123
153
  class Overlap < Check
124
154
  def problem?
@@ -3,7 +3,9 @@
3
3
  module WikidataPositionHistory
4
4
  # Date for a single mandate row, to be passed to the report template
5
5
  class MandateData
6
- CHECKS = [Check::MissingFields, Check::WrongPredecessor, Check::WrongSuccessor, Check::Overlap].freeze
6
+ CHECKS = [Check::MissingFields, Check::Overlap,
7
+ Check::WrongPredecessor, Check::MissingPredecessor,
8
+ Check::WrongSuccessor, Check::MissingSuccessor].freeze
7
9
 
8
10
  def initialize(later, current, earlier)
9
11
  @later = later
@@ -85,6 +87,11 @@ module WikidataPositionHistory
85
87
  rows.map(&:position?).first
86
88
  end
87
89
 
90
+ def legislator?
91
+ # this should be the same everywhere
92
+ rows.map(&:legislator?).first
93
+ end
94
+
88
95
  private
89
96
 
90
97
  attr_reader :rows
@@ -112,9 +119,10 @@ module WikidataPositionHistory
112
119
  attr_reader :position_id, :template_class
113
120
 
114
121
  def wikitext
122
+ return legislator_template if metadata.legislator?
115
123
  return no_items_output if mandates.empty?
116
124
 
117
- output
125
+ template_class.new(template_params).output
118
126
  end
119
127
 
120
128
  def header
@@ -170,8 +178,8 @@ module WikidataPositionHistory
170
178
  "\n{{PositionHolderHistory/error_no_holders|id=#{position_id}}}\n"
171
179
  end
172
180
 
173
- def output
174
- template_class.new(template_params).output
181
+ def legislator_template
182
+ "\n{{PositionHolderHistory/error_legislator|id=#{position_id}}}\n"
175
183
  end
176
184
 
177
185
  def table_rows
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WikidataPositionHistory
4
- VERSION = '1.7.0'
4
+ VERSION = '1.8.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikidata_position_history
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Bowden
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-09-08 00:00:00.000000000 Z
12
+ date: 2020-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mediawiki-replaceable-content