model

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixHeader             = "HE"
	DeputiesToken            = "CD"
	AttendanceToken          = "LP"
	PollToken                = "LV"
	PrefixHeaderDeputies     = PrefixHeader + DeputiesToken
	PrefixPollDeputies       = PollToken + DeputiesToken
	PrefixAttendanceDeputies = AttendanceToken + DeputiesToken
	SuffixAttendance         = "000000"
)
View Source
const (
	WidthAttendedAttendance = 9

	WidthVotePoll = 10

	// Sum of ChamberType, LegislativeSession, LegislativeSessionType,
	// SessionNumber, SessionType + 2 spaces
	WidthSessionInfo = 17

	WidthChamberType            = 2
	WidthLegislativeSession     = 2
	WidthLegislativeSessionType = 1
	WidthSessionNumber          = 3
	WidthSessionType            = 1
	// Last 6 characters of filename.
	// It is not specific to poll related files.
	WidthIDPoll            = 6
	WidthLawmakerName      = 40
	WidthPartyAbbreviation = 10
	WidthStateName         = 25
	WidthLawmakerCode      = 3
	WidthTotal             = 105
)
View Source
const (
	AttendanceEndChamberType            = WidthChamberType
	AttendanceEndLegislativeSession     = AttendanceEndChamberType + WidthLegislativeSession
	AttendanceEndLegislativeSessionType = AttendanceEndLegislativeSession + WidthLegislativeSessionType
	AttendanceEndSessionNumber          = AttendanceEndLegislativeSessionType + WidthSessionNumber
	AttendanceEndSessionType            = AttendanceEndSessionNumber + WidthSessionType
	AttendanceEndPollID                 = AttendanceEndSessionType + WidthIDPoll

	AttendanceEndLawmakerName      = EndSessionInfo + WidthLawmakerName
	AttendanceEndAttended          = AttendanceEndLawmakerName + WidthAttendedAttendance
	AttendanceEndPartyAbbreviation = AttendanceEndAttended + WidthPartyAbbreviation
	AttendanceEndStateName         = AttendanceEndPartyAbbreviation + WidthStateName
	AttendanceEndLawmakerCode      = AttendanceEndStateName + WidthLawmakerCode
)
View Source
const (
	PollEndChamberType            = WidthChamberType
	PollEndLegislativeSession     = PollEndChamberType + WidthLegislativeSession
	PollEndLegislativeSessionType = PollEndLegislativeSession + WidthLegislativeSessionType
	PollEndSessionNumber          = PollEndLegislativeSessionType + WidthSessionNumber
	PollEndSessionType            = PollEndSessionNumber + WidthSessionType
	PollEndPollID                 = PollEndSessionType + WidthIDPoll

	PollEndLawmakerName      = EndSessionInfo + WidthLawmakerName
	PollEndVote              = PollEndLawmakerName + WidthVotePoll
	PollEndPartyAbbreviation = PollEndVote + WidthPartyAbbreviation
	PollEndStateName         = PollEndPartyAbbreviation + WidthStateName
	PollEndLawmakerCode      = PollEndStateName + WidthLawmakerCode
)
View Source
const (
	AttendanceAbsenceToken = "<------>"
	PollAbsenceToken       = "<------->"
)
View Source
const EndSessionInfo = WidthSessionInfo
View Source
const FileFormat = ".txt"
View Source
const HeaderLinesCount = 13

Variables

View Source
var ErrEmptyFile = errors.New("file is empty")

Functions

This section is empty.

Types

type Attendance

type Attendance struct {
	// Width: 2 characters. Possible values: "CD", "CC", "SF"
	ChamberType string `json:"chamber_type"`

	// Width: 2 characters.
	LegislativeSession string `json:"legislative_session"`

	// Width: 1 character. Possible values: "O" or "E"
	LegislativeSessionType string `json:"legislative_session_type"`

	// Width: 3 characters. Is of type string to preserve leading zero.
	// Is unique only per legislative session(x of 4).
	SessionNumber string `json:"session_number"`

	// Width: 1 character. Possible values: "O" or "E"
	SessionType string `json:"session_type"`

	// Width: 6 characters.
	// Is of type string in order to preserve a possible leading
	// zero considering that integers do not have leading zeros.
	// Is unique only per legislative session(x of 4).
	PollID string `json:"poll_id"`

	// Width: 40 characters.
	LawmakerName string `json:"lawmaker_name"`

	// Width: 8 characters + 1(space).
	// The original API possible values are "Presente" on attendance and "<------->" on absence.
	Attended bool `json:"attended"`

	// Width: 10 characters.
	PartyAbbreviation string `json:"party_abbreviation"`

	// Width: 25 characters.
	StateName string `json:"state_name"`

	// Width: 3 characters.
	// Is unique only per legislature.
	LawmakerCode int `json:"lawmaker_code"`
}

type AttendanceHeader

type AttendanceHeader struct {
	// Width: 2 characters. Possible values: "CD", "CC", "SF".
	ChamberType string `json:"chamber_type"`

	// Width: 2 characters.
	LegislativeSession string `json:"legislative_session"`

	// Width: 1 character. Possible values: "O" or "E".
	LegislativeSessionType string `json:"legislative_session_type"`

	// Width: 3 characters.
	// Is of type string to preserve leading zero.
	// Is unique only per legislative session(x of 4).
	SessionNumber string `json:"session_number"`

	// Width: 1 character. Possible values: "O" or "E".
	SessionType string `json:"session_type"`

	// Width: 6 characters.
	// Is of type string in order to preserve a possible leading zero
	// considering that integers do not have leading zeros.
	// Is unique only per legislative session(x of 4).
	PollID string `json:"poll_id"`

	EndDatetime     DateTime `json:"end_datetime"`
	PresidentName   string   `json:"president_name"`
	AttendantsTotal int      `json:"attendants_total"`
}

type AttendanceHeaderRow added in v0.0.3

type AttendanceHeaderRow struct {
	AttendanceHeader

	Legislature int `json:"legislature"`
}

func ParseAttendanceHeader

func ParseAttendanceHeader(rootDir string, filename string, legislature int) (AttendanceHeaderRow, error)

Parse atendance header file and return as struct.

type AttendanceRecord

type AttendanceRecord struct {
	Header      AttendanceHeaderRow `json:"header"`
	Attendances []AttendanceRow     `json:"attendances"`
}

type AttendanceRow added in v0.0.3

type AttendanceRow struct {
	Attendance

	Legislature int `json:"legislature"`
}

func ParseAttendances

func ParseAttendances(rootDir string, filename string, legislature int) ([]AttendanceRow, error)

Returns a slice of attendances parsed from given filepath.

type DateTime added in v0.0.4

type DateTime struct {
	time.Time
}

Implements methods for JSON parsing and database reads/writes with format 2006-01-02T15:04:05.

func (*DateTime) MarshalJSON added in v0.0.4

func (d *DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) Scan added in v0.0.4

func (d *DateTime) Scan(value any) error

Reads from DB

func (*DateTime) UnmarshalJSON added in v0.0.4

func (d *DateTime) UnmarshalJSON(b []byte) error

func (DateTime) Value added in v0.0.4

func (d DateTime) Value() (driver.Value, error)

Writes to DB

type Feed

type Feed struct {
	AttendanceRecords []AttendanceRecord `json:"attendance_records"`
	PollRecords       []PollRecord       `json:"poll_records"`
}

type PollHeader

type PollHeader struct {
	// Width: 2 characters. Possible values: "CD", "CC", "SF".
	ChamberType string `json:"chamber_type"`

	// Width: 2 characters.
	// Is unique only per legislative session(x of 4).
	LegislativeSession string `json:"legislative_session"`

	// Width: 1 character. Possible values: "O" or "E".
	LegislativeSessionType string `json:"legislative_session_type"`

	// Width: 3 characters. Is of type string to preserve leading zero.
	SessionNumber string `json:"session_number"`

	// Width: 1 character. Possible values: "O" or "E".
	SessionType string `json:"session_type"`

	// Is of type string in order to preserve a possible leading zero
	// considering that integers do not have leading zeros.
	// Is unique only per legislative session(x of 4).
	PollID string `json:"poll_id"`

	EndDatetime      DateTime `json:"end_datetime"`
	PresidentName    string   `json:"president_name"`
	VotesYes         int      `json:"votes_yes"`
	VotesNo          int      `json:"votes_no"`
	VotesAbstention  int      `json:"votes_abstention"`
	VotesObstruction int      `json:"votes_obstruction"`
	VotesWhite       int      `json:"votes_white"`
	VotesPresident   int      `json:"votes_president"`
	VotesTotal       int      `json:"votes_total"`
	PropositionName  string   `json:"proposition_name"`
}

type PollHeaderRow added in v0.0.3

type PollHeaderRow struct {
	PollHeader

	Legislature int `json:"legislature"`
}

func ParsePollHeader

func ParsePollHeader(rootDir string, filename string, legislature int) (PollHeaderRow, error)

Parse poll header file and return as struct.

type PollRecord

type PollRecord struct {
	Header PollHeaderRow `json:"header"`
	Votes  []PollVoteRow `json:"votes"`
}

type PollVote

type PollVote struct {
	// Width: 2 characters. Possible values: "CD", "CC", "SF"
	ChamberType string `json:"chamber_type"`

	// Width: 2 characters.
	LegislativeSession string `json:"legislative_session"`

	// Width: 1 character. Possible values: "O" or "E"
	LegislativeSessionType string `json:"legislative_session_type"`

	// Width: 3 characters.
	// Is of type string to preserve leading zero.
	// Is unique only per legislative session(x of 4).
	SessionNumber string `json:"session_number"`

	// Width: 1 character. Possible values: "O" or "E"
	SessionType string `json:"session_type"`

	// Width: 6 characters + 1(space).
	// Is of type string in order to preserve a possible leading zero
	// considering that integers do not have leading zeros.
	// Is unique only per legislative session(x of 4).
	PollID string `json:"poll_id"`

	// Width: 40 characters.
	LawmakerName string `json:"lawmaker_name"`

	// Width: 10 characters.
	// Some of the original API possible values are "Presente" on anonymous polls, "<------->" upon non-participation.
	// "Presente" will be mapped to "present" and non-pariticipation to "absent".
	// The other possible values are "Sim", "Não" , "Abstenção", "Obstrução", "Branco" and "Art. 17" for the president's vote.
	Vote string `json:"vote"`

	// Width: 10 characters.
	PartyAbbreviation string `json:"party_abbreviation"`

	// Width: 25 characters.
	StateName string `json:"state_name"`

	// Width: 3 characters.
	// Is unique only per legislature.
	LawmakerCode int `json:"lawmaker_code"`
}

type PollVoteRow added in v0.0.3

type PollVoteRow struct {
	PollVote

	Legislature int `json:"legislature"`
}

func ParsePollVotes

func ParsePollVotes(rootDir string, filename string, legislature int) ([]PollVoteRow, error)

Returns a slice of poll votes parsed from given filepath.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL