structured_data_to_sql 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a50afe6c834dcd44e699032caa0cdc7edd95b6bb041ccdd24ff2a4e9baf95ea
|
|
4
|
+
data.tar.gz: 2ed49f9f4dedd7be4e163006c75cccaca849e8cab58a487526b00c3326f0c184
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69ec834c19d138f85dc1182d6b2b057b9e6e07dd52a4f6850312216e63c9567603dd0aa8cfd3b817a8e2c14b89c5bd6f5d770eb6f294db85c60cb3f160cfe0e7
|
|
7
|
+
data.tar.gz: 2f671632b40604564a48a55650cd4b07ffd95ddeb8e2046cb2972f37c89af283b9f0cf5b01a7cfd1e05d19b875183e48f225bff7752959f4bdae03f3820a217f
|
|
@@ -150,8 +150,10 @@ module StructuredDataToSql
|
|
|
150
150
|
return lines
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
-
lines << "Quality signals are scoped to the latest run whose manifest entry is `completed`, " \
|
|
154
|
-
"by attributing the last _N_ rows of the append-only errors/gaps files to it (_N_ = that run's declared count)
|
|
153
|
+
lines << "Quality signals are scoped to the latest content run whose manifest entry is `completed`, " \
|
|
154
|
+
"by attributing the last _N_ rows of the append-only errors/gaps files to it (_N_ = that run's declared count), " \
|
|
155
|
+
"less whatever later runs declared. A `structure_repair` run that follows it is reported on its own line; " \
|
|
156
|
+
"a later run that never finalized its entry leaves the breakdown unattributable and it is withheld. " \
|
|
155
157
|
"Rows beyond the sum of declared counts belong to runs that never finalized their entry."
|
|
156
158
|
lines << ""
|
|
157
159
|
lines << "| Run | Status | Started | Finished | Mode | Credential | Emails | Errors | Gaps |"
|
|
@@ -26,6 +26,23 @@ module StructuredDataToSql
|
|
|
26
26
|
def completed?
|
|
27
27
|
status == "completed"
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
# A structure repair appends nodes and its own error/gap rows to an
|
|
31
|
+
# existing export; it is a run, but not the content export the rows
|
|
32
|
+
# were converted from.
|
|
33
|
+
def repair?
|
|
34
|
+
mode == "structure_repair"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def content?
|
|
38
|
+
!repair?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# An entry the exporter closed, whatever the outcome. A run killed
|
|
42
|
+
# outright stays `running` with no counts, so its rows are undeclared.
|
|
43
|
+
def finalized?
|
|
44
|
+
status != "running" && !finished_at.nil?
|
|
45
|
+
end
|
|
29
46
|
end
|
|
30
47
|
|
|
31
48
|
FILENAME = "manifest.json"
|
|
@@ -64,8 +81,24 @@ module StructuredDataToSql
|
|
|
64
81
|
parse
|
|
65
82
|
end
|
|
66
83
|
|
|
84
|
+
# The latest completed content run: what the quality signals are scoped to.
|
|
67
85
|
def latest_completed
|
|
68
|
-
@runs.reverse.find
|
|
86
|
+
@runs.reverse.find { |run| run.completed? && run.content? }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def latest_completed_repair
|
|
90
|
+
@runs.reverse.find { |run| run.completed? && run.repair? }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Rows declared by the runs after +run+. The files are append-only, so a
|
|
94
|
+
# run's rows end where the next run's begin.
|
|
95
|
+
def rows_after(run, counter)
|
|
96
|
+
@runs.drop(run.index + 1).sum(&counter)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Later runs whose rows are not declared, so their position is unknown.
|
|
100
|
+
def unfinalized_after(run)
|
|
101
|
+
@runs.drop(run.index + 1).reject(&:finalized?)
|
|
69
102
|
end
|
|
70
103
|
|
|
71
104
|
def errors_total
|
|
@@ -718,7 +718,7 @@ module StructuredDataToSql
|
|
|
718
718
|
latest = manifest.latest_completed
|
|
719
719
|
if latest.nil?
|
|
720
720
|
return [
|
|
721
|
-
"Latest run: not scoped — no completed run in manifest.json; showing lifetime totals"
|
|
721
|
+
"Latest run: not scoped — no completed content run in manifest.json; showing lifetime totals"
|
|
722
722
|
]
|
|
723
723
|
end
|
|
724
724
|
|
|
@@ -730,22 +730,77 @@ module StructuredDataToSql
|
|
|
730
730
|
]
|
|
731
731
|
end
|
|
732
732
|
|
|
733
|
-
|
|
734
|
-
latest_rows = @quality_signal_rows[table].last(latest_count)
|
|
735
|
-
latest_tallies = Hash.new(0)
|
|
736
|
-
latest_rows.each { |label| latest_tallies[label] += 1 }
|
|
737
|
-
window = [latest.started_at, latest.finished_at].compact.join(" → ")
|
|
733
|
+
unattributed = total - declared
|
|
738
734
|
lines = [
|
|
739
|
-
|
|
740
|
-
"
|
|
735
|
+
attributed_line(
|
|
736
|
+
"Latest completed run",
|
|
737
|
+
latest,
|
|
738
|
+
manifest,
|
|
739
|
+
table,
|
|
740
|
+
counter,
|
|
741
|
+
total,
|
|
742
|
+
unattributed
|
|
743
|
+
)
|
|
741
744
|
]
|
|
742
|
-
|
|
745
|
+
repair = manifest.latest_completed_repair
|
|
746
|
+
if repair && repair.index > latest.index
|
|
747
|
+
lines << attributed_line(
|
|
748
|
+
"Latest structure repair",
|
|
749
|
+
repair,
|
|
750
|
+
manifest,
|
|
751
|
+
table,
|
|
752
|
+
counter,
|
|
753
|
+
total,
|
|
754
|
+
unattributed
|
|
755
|
+
)
|
|
756
|
+
end
|
|
743
757
|
if unattributed.positive?
|
|
744
758
|
lines << "Unattributed: #{Format.format_count(unattributed)} row(s) written by runs that did not finalize their manifest entry"
|
|
745
759
|
end
|
|
746
760
|
lines
|
|
747
761
|
end
|
|
748
762
|
|
|
763
|
+
# A run's rows sit before whatever later runs appended, so its slice
|
|
764
|
+
# ends where theirs begin — provided every later run declared its
|
|
765
|
+
# rows. Undeclared rows that may sit after this run's make the slice a
|
|
766
|
+
# guess, and a guess is not shown as a breakdown.
|
|
767
|
+
def attributed_line(
|
|
768
|
+
label,
|
|
769
|
+
run,
|
|
770
|
+
manifest,
|
|
771
|
+
table,
|
|
772
|
+
counter,
|
|
773
|
+
total,
|
|
774
|
+
unattributed
|
|
775
|
+
)
|
|
776
|
+
count = run.public_send(counter)
|
|
777
|
+
window = [run.started_at, run.finished_at].compact.join(" → ")
|
|
778
|
+
head =
|
|
779
|
+
"#{label} ##{run.index}#{window.empty? ? "" : " (#{window})"}: " \
|
|
780
|
+
"#{Format.format_count(count)}"
|
|
781
|
+
undeclared =
|
|
782
|
+
unattributed.positive? ? manifest.unfinalized_after(run) : []
|
|
783
|
+
unless undeclared.empty?
|
|
784
|
+
blamed =
|
|
785
|
+
undeclared
|
|
786
|
+
.map { |later| "##{later.index} (#{later.status})" }
|
|
787
|
+
.join(", ")
|
|
788
|
+
return(
|
|
789
|
+
"#{head} — breakdown not attributable: run #{blamed} did not finalize its " \
|
|
790
|
+
"entry, so undeclared rows may sit after this run's"
|
|
791
|
+
)
|
|
792
|
+
end
|
|
793
|
+
return head unless count.positive?
|
|
794
|
+
|
|
795
|
+
after = manifest.rows_after(run, counter)
|
|
796
|
+
tallies = Hash.new(0)
|
|
797
|
+
@quality_signal_rows[table]
|
|
798
|
+
.first(total - after)
|
|
799
|
+
.last(count)
|
|
800
|
+
.each { |row_label| tallies[row_label] += 1 }
|
|
801
|
+
"#{head} — #{breakdown_text(tallies)}"
|
|
802
|
+
end
|
|
803
|
+
|
|
749
804
|
def breakdown_text(tallies)
|
|
750
805
|
tallies
|
|
751
806
|
.sort_by { |label, count| [-count, label] }
|