-
Notifications
You must be signed in to change notification settings - Fork 2
/
db_matter.go
221 lines (190 loc) · 5.08 KB
/
db_matter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
package db
import (
"strings"
"time"
"github.com/jehiah/legislator/legistar"
)
// NOTE: Struct ordering affects JSON format
type Legislation struct {
ID int
GUID string
File string
LocalLaw string `json:",omitempty"` // format: $year/$number
Name string
Title string
TypeID int
TypeName string
StatusID int
StatusName string
BodyID int
BodyName string
IntroDate time.Time
AgendaDate time.Time
PassedDate time.Time
EnactmentDate time.Time
Version string `json:",omitempty"`
Sponsors []PersonReference `json:",omitempty"`
History []History `json:",omitempty"`
Attachments []Attachment `json:",omitempty"`
Summary string // MatterEXText5
TextID int `json:",omitempty"`
Text string `json:",omitempty"` // current version
RTF string `json:",omitempty"` // current version
LastModified time.Time
}
// Shallow returns a copy of l with details about the text and sponsors ommitted
func (l Legislation) Shallow() Legislation {
l.Version = ""
l.Text = ""
l.TextID = 0
l.RTF = ""
l.Sponsors = nil
return l
}
func NewLegislation(m legistar.Matter) Legislation {
l := Legislation{
ID: m.ID,
GUID: m.GUID,
File: m.File,
LocalLaw: m.EnactmentNumber,
Name: m.Name,
Title: m.Title,
TypeID: m.TypeID,
TypeName: m.TypeName,
StatusID: m.StatusID,
StatusName: m.StatusName,
BodyID: m.BodyID,
BodyName: m.BodyName,
IntroDate: m.IntroDate.Time,
AgendaDate: m.AgendaDate.Time,
PassedDate: m.PassedDate.Time,
EnactmentDate: m.EnactmentDate.Time,
Version: m.Version,
Summary: m.EXText5,
LastModified: m.LastModified.Time,
}
return l
}
type History struct {
ID int
// GUID string
Date time.Time
ActionID int
Action string
Description string
BodyID int
BodyName string
EventID int `json:",omitempty"`
AgendaSequence int `json:",omitempty"`
MinutesSequence int `json:",omitempty"`
AgendaNumber string `json:",omitempty"`
Video int `json:",omitempty"`
VideoIndex int `json:",omitempty"`
Version string
AgendaNote string `json:",omitempty"`
MinutesNote string `json:",omitempty"`
PassedFlag int `json:",omitempty"` // Note: 0 may indicate a vote that failed
PassedFlagName string `json:",omitempty"` // Pass, Fail
RollCallFlag int `json:",omitempty"`
FlagExtra int `json:",omitempty"`
Tally string `json:",omitempty"`
AccelaRecordID string `json:",omitempty"`
Consent int `json:",omitempty"`
MoverID int `json:",omitempty"`
MoverName string `json:",omitempty"`
SeconderID int `json:",omitempty"`
SeconderName string `json:",omitempty"`
MatterStatusID int
Votes []Vote `json:",omitempty"`
LastModified time.Time
}
func NewHistory(h legistar.MatterHistory) History {
return History{
ID: h.ID,
// GUID: h.GUID,
Date: h.ActionDate.Time,
ActionID: h.ActionID,
Action: h.ActionName,
Description: h.ActionText,
BodyID: h.ActionBodyID,
BodyName: h.ActionBodyName,
EventID: h.EventID,
AgendaSequence: h.AgendaSequence,
MinutesSequence: h.MinutesSequence,
AgendaNumber: h.AgendaNumber,
Video: h.Video,
VideoIndex: h.VideoIndex,
Version: h.Version,
AgendaNote: h.AgendaNote,
MinutesNote: h.MinutesNote,
PassedFlag: h.PassedFlag,
PassedFlagName: h.PassedFlagName,
RollCallFlag: h.RollCallFlag,
FlagExtra: h.FlagExtra,
Tally: h.Tally,
AccelaRecordID: h.AccelaRecordID,
Consent: h.Consent,
MoverID: h.MoverID,
MoverName: h.MoverName,
SeconderID: h.SeconderID,
SeconderName: h.SeconderName,
MatterStatusID: h.MatterStatusID,
LastModified: h.LastModified.Time,
}
}
type Attachment struct {
ID int
LastModified time.Time
Name string
Link string
// MatterVersion string
// IsSupportingDocument bool
// ShowOnInternetPage bool
// IsMinuteOrder bool
// IsBoardLetter bool
// AgiloftID int
// Description string
// PrintWithReports bool
Sort int
}
func NewAttachment(h legistar.MatterAttachment) Attachment {
return Attachment{
ID: h.ID,
LastModified: h.LastModified.Time,
Name: h.Name,
Link: h.Link,
Sort: h.Sort,
}
}
type Vote struct {
PersonReference
VoteID int
Vote string // Afffirmative, Negative, Absent
Result int `json:",omitempty"` // 1 = Afirmative, 2 = Negative
Sort int
}
type Votes []Vote
func NewVotes(v legistar.Votes) Votes {
var o Votes
for _, vv := range v {
o = append(o, NewVote(vv))
}
return o
}
func NewVote(v legistar.Vote) Vote {
return Vote{
PersonReference: PersonReference{
FullName: strings.TrimSpace(v.PersonName),
ID: v.PersonID,
Slug: v.Slug(),
},
VoteID: v.ValueID,
Vote: strings.TrimSpace(v.ValueName),
Result: v.Result,
Sort: v.Sort,
}
}
type ResubmitLegislation struct {
FromFile string
ToFile string
}