Skip to content

Commit

Permalink
Merge pull request #88 from projetoKhali/fix-back-final
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-granthon authored Dec 4, 2024
2 parents 53837f5 + 43ea2b3 commit a99f99a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
Binary file modified etl/dados_dw_nova.xlsx
Binary file not shown.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ func main() {

// Middleware para medir métricas personalizadas
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
w.Header().Set("Content-Type", "*/*")
if r.Method == "OPTIONS" {
return
}

start := time.Now()

// Incrementar contador de requisições
Expand Down
12 changes: 8 additions & 4 deletions scripts/seeds/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,27 @@ import (
type SeedsPreset struct {
Abbreviation string
Name string
Database string
SeedsFunc func(client *ent.Client) error
}

var SeedsPresets = []SeedsPreset{
{
Abbreviation: "dw",
Name: "data-warehouse",
Database: "DW",
SeedsFunc: seeds.DataWarehouse,
},
{
Abbreviation: "db",
Name: "DataRelational",
Database: "DB",
SeedsFunc: seeds.DataRelational,
},
{
Abbreviation: "phpc",
Abbreviation: "pdc",
Name: "ProceduralDimCandidates",
Database: "DW",
SeedsFunc: seeds.DwProceduralDimCandidates,
},
}
Expand Down Expand Up @@ -71,8 +75,8 @@ func main() {
buildAvailableSeedsMessage(&sb)
sb.WriteString("You can run a seed by providing its name or abbreviation as an argument.\n")
sb.WriteString("Example:\n")
sb.WriteString(" go run scripts/seeds.go DataWarehouse\n")
sb.WriteString(" go run scripts/seeds.go dw\n")
sb.WriteString(fmt.Sprintf(" go run scripts/seeds.go %s\n", SeedsPresets[0].Name))
sb.WriteString(fmt.Sprintf(" go run scripts/seeds.go %s\n", SeedsPresets[0].Abbreviation))
panic(sb.String())
}

Expand Down Expand Up @@ -115,5 +119,5 @@ func main() {
}
}

seeds.Execute("DW", targetSeedsPreset.SeedsFunc)
seeds.Execute(targetSeedsPreset.Database, targetSeedsPreset.SeedsFunc)
}
6 changes: 3 additions & 3 deletions seeds/db_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func DataRelational(client *ent.Client) error {
{Name: "Vendas", GroupIDs: []int{3, 5}},
}

groupAccessIds := []int{}
accessGroupIds := []int{}
for _, g := range groups {
group, err := client.
AccessGroup.
Expand All @@ -59,7 +59,7 @@ func DataRelational(client *ent.Client) error {
if err != nil {
return fmt.Errorf("failed to create Group Access %s: %v", g.Name, err)
}
groupAccessIds = append(groupAccessIds, group.ID)
accessGroupIds = append(accessGroupIds, group.ID)
}

relations := []struct {
Expand All @@ -77,7 +77,7 @@ func DataRelational(client *ent.Client) error {
dept := departmentIDs[rel.DepartmentID-1]
groupsIDs := []int{}
for _, relationGroupID := range rel.GroupIDs {
groupsIDs = append(groupsIDs, groupAccessIds[relationGroupID-1])
groupsIDs = append(groupsIDs, accessGroupIds[relationGroupID-1])
}

err := client.
Expand Down
2 changes: 1 addition & 1 deletion src/property/dim_candidate_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestParseDimCandidateStatus(t *testing.T) {
} {
t.Run(testCase.Name, func(t *testing.T) {
testFunction := func() {
status := HiringProcessCandidateStatus(0)
status := DimCandidateStatus(0)
err := status.Scan(testCase.IntValue)
if err != nil {
require.Equal(t, testCase.ExpectedStatus, "")
Expand Down
12 changes: 7 additions & 5 deletions src/server/hiring_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ func HiringProcessDashboard(
suggestions := v1.Group("/suggestions")
{
suggestions.POST("/recruiter", UserList(dwClient))
suggestions.POST("/process", HiringProcessList((dwClient)))
suggestions.POST("/process", HiringProcessList(dwClient))
suggestions.POST("/vacancy", VacancyList(dwClient))
suggestions.GET("/department", ListDepartments(dbClient))
}

authentication := v1.Group("/authentication")
{
authentication.GET("/users", ListUsers(dbClient))
authentication.POST("/login", LoginUser(dbClient))
authentication.POST("/create", CreateUser(dbClient))
}
groupAccess := v1.Group("/access-group")

accessGroup := v1.Group("/access-group")
{
groupAccess.GET("", ListAccessGroup(dbClient))
groupAccess.POST("", CreateAccessGroup(dbClient))
accessGroup.GET("", ListAccessGroup(dbClient))
accessGroup.POST("", CreateAccessGroup(dbClient))
}
}
}
Expand Down Expand Up @@ -222,7 +224,7 @@ func VacancyTable(
// @Tags departments
// @Produce json
// @Success 200 {array} model.Suggestion
// @Router /suggestions/departments [get]
// @Router /suggestions/department [get]
func ListDepartments(
client *ent.Client,
) func(c *gin.Context) {
Expand Down
14 changes: 8 additions & 6 deletions src/service/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ func applyFactHiringProcessQueryFilters(
query *ent.FactHiringProcessQuery,
filter model.FactHiringProcessFilter,
) (*ent.FactHiringProcessQuery, error) {
query = query.Where(
facthiringprocess.HasDimProcessWith(
dimprocess.HasDimDepartmentWith(
dimdepartment.IDIn(filter.AccessGroups...),
if filter.AccessGroups != nil && len(filter.AccessGroups) > 0 {
query = query.Where(
facthiringprocess.HasDimProcessWith(
dimprocess.HasDimDepartmentWith(
dimdepartment.IDIn(filter.AccessGroups...),
),
),
),
)
)
}
if filter.Recruiters != nil && len(filter.Recruiters) > 0 {
query = query.Where(
facthiringprocess.HasDimUserWith(
Expand Down

0 comments on commit a99f99a

Please sign in to comment.