models

package
v0.0.0-...-457b880 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMongoInstance

func GetMongoInstance() (*mongo.Client, context.Context, context.CancelFunc)

Get a Mongo instance (Client, Context, Cancel)

func RedisExists

func RedisExists(key string) (bool, error)

Check if a key exists in redis

func RedisGet

func RedisGet(key string) ([]byte, error)

Get a value from redis

func RedisGetSlice

func RedisGetSlice(key string) ([][]byte, error)

Get a slice of values from redis

func RedisSet

func RedisSet(key string, value interface{}) error

Set the value for a key in redis

func RedisTTL

func RedisTTL(key string, ttl int) error

Set the ttl for a key in redis

func Setup

func Setup()

Setup Environment variables and make sure database is initialized

func SetupCache

func SetupCache()

Setup the cache

Types

type Box

type Box struct {
	Id             primitive.ObjectID `json:"_id" bson:"_id"`
	Number         int64              `json:"number" bson:"number"`             // 1001
	City           string             `json:"city" bson:"city"`                 // Ankara
	CityNumber     int64              `json:"citynumber" bson:"citynumber"`     // 6
	Constituency   string             `json:"constituency" bson:"constituency"` // Ankara-1
	District       string             `json:"district" bson:"district"`         // Çankaya
	Quarter        string             `json:"quarter" bson:"quarter"`           // Çukurambar
	Candidates     []CandidateInBox   `json:"candidates" bson:"candidates"`
	EligibleVoters int64              `json:"eligiblevoters" bson:"eligiblevoters"` // 12621
	ActualVoters   int64              `json:"actualvoters" bson:"actualvoters"`     // 10262
	ValidVotes     int64              `json:"validvotes" bson:"validvotes"`         // 10101
	InvalidVotes   int64              `json:"invalidvotes" bson:"invalidvotes"`     // 161
	SST            string             `json:"sst" bson:"sst"`                       // 24923948264 (Static File Storage Microservice)
	SDC            string             `json:"sdc" bson:"sdc"`                       // 42424234242 (Static File Storage Microservice)
}

Model for the ballot box object

type CandidateInBox

type CandidateInBox struct {
	FirstName string `json:"firstname" bson:"firstname"` // Recep Tayyip
	LastName  string `json:"lastname" bson:"lastname"`   // Erdogan
	Votes     int64  `json:"votes" bson:"votes"`         // 121
}

Model for a Party in a Box

type CandidateInResult

type CandidateInResult struct {
	FirstName  string  `json:"firstname" bson:"firstname"`
	LastName   string  `json:"lastname" bson:"lastname"`
	Percentage float32 `json:"percentage" bson:"percentage"`
}

Model for the candidate in a result

type City

type City struct {
	Id             primitive.ObjectID `json:"_id" bson:"_id"`
	Name           string             `json:"name" bson:"name" validate:"required"`             // ankara
	ReadableName   string             `json:"readablename" bson:"readablename"`                 // Ankara
	Number         int64              `json:"number" bson:"number" validate:"required,numeric"` // 6
	Candidates     []CandidateInBox   `json:"candidates" bson:"candidates"`
	EligibleVoters int64              `json:"eligiblevoters" bson:"eligiblevoters" validate:"numeric"` // 12621
	ActualVoters   int64              `json:"actualvoters" bson:"actualvoters" validate:"numeric"`     // 10262
	ValidVotes     int64              `json:"validvotes" bson:"validvotes" validate:"numeric"`         // 10101
	InvalidVotes   int64              `json:"invalidvotes" bson:"invalidvotes" validate:"numeric"`     // 161
}

Model for the city

type Constituency

type Constituency struct {
	Id             primitive.ObjectID `json:"_id" bson:"_id"`
	Name           string             `json:"name" bson:"name" validate:"required"`                     // ankara-1
	ReadableName   string             `json:"readablename" bson:"readablename"`                         // Ankara-01
	City           string             `json:"city" bson:"city" validate:"required"`                     // Ankara
	CityNumber     int64              `json:"citynumber" bson:"citynumber" validate:"required,numeric"` // 6
	Candidates     []CandidateInBox   `json:"candidates" bson:"candidates"`
	EligibleVoters int64              `json:"eligiblevoters" bson:"eligiblevoters"` // 12621
	ActualVoters   int64              `json:"actualvoters" bson:"actualvoters"`     // 10262
	ValidVotes     int64              `json:"validvotes" bson:"validvotes"`         // 10101
	InvalidVotes   int64              `json:"invalidvotes" bson:"invalidvotes"`     // 161
}

Model for the constituency

type District

type District struct {
	Id             primitive.ObjectID `json:"_id" bson:"_id"`
	Name           string             `json:"name" bson:"name"`                 // cankaya
	ReadableName   string             `json:"readablename" bson:"readablename"` // Cankaya
	City           string             `json:"city" bson:"city"`                 // ankara
	CityNumber     int64              `json:"citynumber" bson:"citynumber"`     // 6
	Constituency   string             `json:"constituency" bson:"constituency"` // ankara-1
	Candidates     []CandidateInBox   `json:"candidates" bson:"candidates"`
	EligibleVoters int64              `json:"eligiblevoters" bson:"eligiblevoters"` // 12621
	ActualVoters   int64              `json:"actualvoters" bson:"actualvoters"`     // 10262
	ValidVotes     int64              `json:"validvotes" bson:"validvotes"`         // 10101
	InvalidVotes   int64              `json:"invalidvotes" bson:"invalidvotes"`     // 161
}

Model for the district

type Quarter

type Quarter struct {
	Id             primitive.ObjectID `json:"_id" bson:"_id"`
	Name           string             `json:"name" bson:"name"`                 // mahalle
	ReadableName   string             `json:"readablename" bson:"readablename"` // Mahalle
	City           string             `json:"city" bson:"city"`                 // Ankara
	CityNumber     int64              `json:"citynumber" bson:"citynumber"`     // 6
	Constituency   string             `json:"constituency" bson:"constituency"` // ankara-1
	District       string             `json:"district" bson:"district"`         // Cankaya
	Candidates     []CandidateInBox   `json:"candidates" bson:"candidates"`
	EligibleVoters int64              `json:"eligiblevoters" bson:"eligiblevoters"` // 12621
	ActualVoters   int64              `json:"actualvoters" bson:"actualvoters"`     // 10262
	ValidVotes     int64              `json:"validvotes" bson:"validvotes"`         // 10101
	InvalidVotes   int64              `json:"invalidvotes" bson:"invalidvotes"`     // 161
}

Model for the quarter

type RedisConnectionOptions

type RedisConnectionOptions struct {
	Host        string
	Password    string
	MaxIdle     int
	MaxActive   int
	IdleTimeout time.Duration
}

RedisConnection Options struct

type Result

type Result struct {
	Location   string              `json:"location" bson:"location"`
	Candidates []CandidateInResult `json:"candidates" bson:"candidates"`
}

Model for the results

Jump to

Keyboard shortcuts

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