Skip to content

Commit

Permalink
update Nov 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Nov 28, 2023
1 parent b5b59b1 commit 521536a
Show file tree
Hide file tree
Showing 10 changed files with 2,191 additions and 249 deletions.
3 changes: 2 additions & 1 deletion cmd/sif_populate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var teacherjudgement = flag.Bool("teacherjudgement", false, "Generate teacher ju
var timetable = flag.Bool("timetable", false, "Generate timetable use case input data")
var wellbeing = flag.Bool("wellbeing", false, "Generate wellbeing use case input data")
var agcollections = flag.Bool("agcollections", false, "Generate AG collections use case input data")
var stdn = flag.Bool("stdn", false, "Generate Student Data Transfer Note use case input data")
var studentcount = flag.Int("studentcount", 400, "Number of StudentPersonal objects to generate")
var staffcount = flag.Int("staffcount", 40, "Number of StaffPersonal objects to generate")
var schoolcount = flag.Int("schoolcount", 10, "Number of SchoolInfo objects to generate")
Expand All @@ -26,7 +27,7 @@ var vendorcount = flag.Int("vendorcount", 10, "Number of VendorInfo objects to g
func main() {
flag.Parse()

usecases := populate.MakeUsecases{Enrolment: *enrolment, Provisioning: *provisioning, DailyAttendance: *dailyattendance, Financial: *financial, Gradebook: *gradebook, StudentAttendanceTimeList: *studentattendancetimelist, TeacherJudgement: *teacherjudgement, Timetable: *timetable, Wellbeing: *wellbeing, AGCollections: *agcollections}
usecases := populate.MakeUsecases{Enrolment: *enrolment, Provisioning: *provisioning, DailyAttendance: *dailyattendance, Financial: *financial, Gradebook: *gradebook, StudentAttendanceTimeList: *studentattendancetimelist, TeacherJudgement: *teacherjudgement, Timetable: *timetable, Wellbeing: *wellbeing, AGCollections: *agcollections, StudentDataTransferNote: *stdn}
counts := populate.MakeUsecaseCounts{Students: *studentcount, Staff: *staffcount, Schools: *schoolcount, Vendors: *vendorcount}
log.Printf("%+v", usecases)
log.Printf("%+v", counts)
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/nsip/sifxml2go

go 1.20
go 1.21

toolchain go1.21.2

require (
github.com/brianvoe/gofakeit/v5 v5.11.1
Expand All @@ -9,3 +11,5 @@ require (
github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494
github.com/rickar/cal/v2 v2.0.0-beta.2
)

require github.com/brianvoe/gofakeit/v6 v6.25.0 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/brianvoe/gofakeit/v5 v5.11.1 h1:PxJu5+or2fM+MqEwLsKc7GmWzRXNHDzvbo4Xvj0J1o4=
github.com/brianvoe/gofakeit/v5 v5.11.1/go.mod h1:/ZENnKqX+XrN8SORLe/fu5lZDIo1tuPncWuRD+eyhSI=
github.com/brianvoe/gofakeit/v6 v6.25.0 h1:ZpFjktOpLZUeF8q223o0rUuXtA+m5qW5srjvVi+JkXk=
github.com/brianvoe/gofakeit/v6 v6.25.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
42 changes: 39 additions & 3 deletions populate/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"time"

"github.com/brianvoe/gofakeit/v5"
"github.com/brianvoe/gofakeit/v6"
"github.com/google/uuid"
"github.com/nsip/sifxml2go/sifxml"
)
Expand Down Expand Up @@ -59,6 +59,14 @@ func this_year() string {
return strconv.Itoa(time.Now().Year())
}

func create_boolean() bool {
r := rand.Float64()
if r < 0.5 {
return true
}
return false
}

func sex_seeded(sex string) string {
r := rand.Float64()
if r < 0.1 {
Expand Down Expand Up @@ -241,10 +249,11 @@ func create_commercial_email_domain() string {
}

func create_phone_number(state *string) string {
var areacode string
if state == nil {
return "04"
val := "Other"
state = &val
}
var areacode string
switch *state {
case "ACT":
areacode = "02"
Expand Down Expand Up @@ -467,10 +476,12 @@ func Term_end_date(year string, semester int) string {
}
}

// List of all codes for Australian Government Collections, to iterate through
func All_AGCollections() []string {
return ([]string{"COI", "FQ", "SES", "STATS"})
}

// Map Australian Government Collection code to human-readable name
func CollectionCode2Name(code string) string {
switch code {
case "COI":
Expand All @@ -485,10 +496,12 @@ func CollectionCode2Name(code string) string {
return "XXX"
}

// Generate a code for the given collection round
func CollectionRoundCode(collection string, year string, round int) string {
return fmt.Sprintf("%s %s-%02d", collection, year, round)
}

// Map supported HTTP status code to human-readable title
func HTTPStatus2Text(code string) string {
switch code {
case "201":
Expand All @@ -500,3 +513,26 @@ func HTTPStatus2Text(code string) string {
}
return "XXX"
}

// Use the fake person generator to generate a person with the given gender
// Supported genders: "male", "female"
func GenderedFakePerson(gender string) *gofakeit.PersonInfo {
var p *gofakeit.PersonInfo
for ok := true; ok; ok = (p.Gender != gender) {
p = gofakeit.Person()
}
return p
}

type PersonInfo struct {
gofakeit.PersonInfo
MiddleName string
}

func FakePerson() *PersonInfo {
person := gofakeit.Person()
person2 := GenderedFakePerson(person.Gender)
ret := PersonInfo{PersonInfo: *person}
ret.MiddleName = person2.FirstName
return &ret
}
Loading

0 comments on commit 521536a

Please sign in to comment.