104 lines
4.2 KiB
Go
104 lines
4.2 KiB
Go
// Package opportunity calculates transparent labor-market signals. It does
|
|
// not predict whether an individual will be hired.
|
|
package opportunity
|
|
|
|
import (
|
|
"errors"
|
|
"math"
|
|
"time"
|
|
)
|
|
|
|
const FormulaVersion = "az-employability-outlook-v1"
|
|
|
|
var ErrInsufficientEvidence = errors.New("insufficient evidence for employability outlook")
|
|
|
|
type Evidence struct {
|
|
ArizonaAnnualGraduates int `json:"arizona_annual_graduates"`
|
|
ArizonaProjectedOpenings int `json:"arizona_projected_annual_openings"`
|
|
ActiveEntryLevelPostings int `json:"active_entry_level_postings"`
|
|
GraduateAcademicYear string `json:"graduate_academic_year"`
|
|
ProjectionPeriod string `json:"projection_period"`
|
|
PostingsObservedAt time.Time `json:"postings_observed_at"`
|
|
Geography string `json:"geography"`
|
|
SOCToCIPMappingCoverage float64 `json:"soc_to_cip_mapping_coverage"`
|
|
GraduateSourceURL string `json:"graduate_source_url"`
|
|
ProjectionSourceURL string `json:"projection_source_url"`
|
|
PostingSourceURL string `json:"posting_source_url"`
|
|
}
|
|
|
|
type Outlook struct {
|
|
FormulaVersion string `json:"formula_version"`
|
|
EmployabilityOutlookPercent int `json:"employability_outlook_percent"`
|
|
AnnualDemandCoveragePercent int `json:"annual_demand_coverage_percent"`
|
|
LivePostingCoveragePercent int `json:"live_posting_coverage_percent"`
|
|
AnnualDemandToGraduateRatio float64 `json:"annual_demand_to_graduate_ratio"`
|
|
Label string `json:"label"`
|
|
Confidence string `json:"confidence"`
|
|
Limitations []string `json:"limitations"`
|
|
Evidence Evidence `json:"evidence"`
|
|
}
|
|
|
|
// Calculate uses projected annual openings for the stable 75-percent signal
|
|
// and a current entry-level posting snapshot for the remaining 25 percent.
|
|
// The result is market context, not a personal hiring probability.
|
|
func Calculate(evidence Evidence) (Outlook, error) {
|
|
if evidence.ArizonaAnnualGraduates <= 0 || evidence.ArizonaProjectedOpenings < 0 || evidence.ActiveEntryLevelPostings < 0 {
|
|
return Outlook{}, ErrInsufficientEvidence
|
|
}
|
|
if evidence.GraduateAcademicYear == "" || evidence.ProjectionPeriod == "" || evidence.PostingsObservedAt.IsZero() || evidence.Geography == "" {
|
|
return Outlook{}, ErrInsufficientEvidence
|
|
}
|
|
if evidence.GraduateSourceURL == "" || evidence.ProjectionSourceURL == "" || evidence.PostingSourceURL == "" {
|
|
return Outlook{}, ErrInsufficientEvidence
|
|
}
|
|
if evidence.SOCToCIPMappingCoverage <= 0 || evidence.SOCToCIPMappingCoverage > 1 {
|
|
return Outlook{}, ErrInsufficientEvidence
|
|
}
|
|
|
|
annualRatio := float64(evidence.ArizonaProjectedOpenings) / float64(evidence.ArizonaAnnualGraduates)
|
|
liveRatio := float64(evidence.ActiveEntryLevelPostings) / float64(evidence.ArizonaAnnualGraduates)
|
|
annualCoverage := cappedPercent(annualRatio)
|
|
liveCoverage := cappedPercent(liveRatio)
|
|
outlookPercent := int(math.Round(float64(annualCoverage)*0.75 + float64(liveCoverage)*0.25))
|
|
|
|
confidence := "lower"
|
|
if evidence.SOCToCIPMappingCoverage >= 0.8 {
|
|
confidence = "higher"
|
|
} else if evidence.SOCToCIPMappingCoverage >= 0.5 {
|
|
confidence = "moderate"
|
|
}
|
|
|
|
return Outlook{
|
|
FormulaVersion: FormulaVersion,
|
|
EmployabilityOutlookPercent: outlookPercent,
|
|
AnnualDemandCoveragePercent: annualCoverage,
|
|
LivePostingCoveragePercent: liveCoverage,
|
|
AnnualDemandToGraduateRatio: math.Round(annualRatio*100) / 100,
|
|
Label: outlookLabel(outlookPercent),
|
|
Confidence: confidence,
|
|
Limitations: []string{
|
|
"Rough market estimate—not your chance of being hired.",
|
|
"Current postings are a changing snapshot and may contain incomplete entry-level labels.",
|
|
"Graduates may enter other occupations, and workers may enter without a mapped Arizona program.",
|
|
},
|
|
Evidence: evidence,
|
|
}, nil
|
|
}
|
|
|
|
func cappedPercent(ratio float64) int {
|
|
return int(math.Round(math.Min(1, math.Max(0, ratio)) * 100))
|
|
}
|
|
|
|
func outlookLabel(percent int) string {
|
|
switch {
|
|
case percent >= 80:
|
|
return "strong demand relative to recent graduates"
|
|
case percent >= 50:
|
|
return "moderate demand relative to recent graduates"
|
|
case percent >= 25:
|
|
return "competitive market"
|
|
default:
|
|
return "limited visible demand relative to recent graduates"
|
|
}
|
|
}
|