Skip to content

Commit

Permalink
v1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
zani0x03 committed Feb 16, 2024
1 parent d08512f commit 02ce926
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 109 deletions.
2 changes: 1 addition & 1 deletion integration_platform_clickup_go/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"console": "externalTerminal",
// "args": ["-iv", "journey"]
// "args": ["-ii", "journey"]
}

]
Expand Down
2 changes: 1 addition & 1 deletion integration_platform_clickup_go/gerarCompilado.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

version="v01.00.05"
version="v01.00.06"
mainFileName="IntegrationPlatformClickup"
fileNameCompact=""
auxFileName=""
Expand Down
108 changes: 72 additions & 36 deletions integration_platform_clickup_go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"integration_platform_clickup_go/services/service_conviso_platform"
"integration_platform_clickup_go/types/type_clickup"
"integration_platform_clickup_go/types/type_enum/enum_clickup_ps_team"
"integration_platform_clickup_go/types/type_enum/enum_clickup_type_consulting"
"integration_platform_clickup_go/types/type_enum/enum_clickup_statuses"
"integration_platform_clickup_go/types/type_enum/enum_clickup_type_ps_hierarchy"
"integration_platform_clickup_go/types/type_enum/enum_main_action"
"integration_platform_clickup_go/types/type_platform"
"integration_platform_clickup_go/utils/functions"
"integration_platform_clickup_go/utils/variables_constant"
Expand Down Expand Up @@ -66,7 +68,6 @@ func MenuSetupConfig() {
}
switch input {
case 0:
break
case 1:
LoadProjects()
default:
Expand All @@ -76,8 +77,8 @@ func MenuSetupConfig() {
}

func VerifyErrorsProjectWithStore(list type_clickup.ListResponse) {
VerifySubtask(list, int(enum_clickup_type_consulting.EPIC), int(enum_clickup_type_consulting.STORE))
VerifySubtask(list, int(enum_clickup_type_consulting.STORE), int(enum_clickup_type_consulting.TASK))
VerifySubtask(list, int(enum_clickup_type_ps_hierarchy.EPIC), int(enum_clickup_type_ps_hierarchy.STORE))
VerifySubtask(list, int(enum_clickup_type_ps_hierarchy.STORE), int(enum_clickup_type_ps_hierarchy.TASK))
VerifyTasks(list)
}

Expand All @@ -87,7 +88,7 @@ func VerifyTasks(list type_clickup.ListResponse) {

for {

tasks, err := service_clickup.ReturnTasks(list.Id, int(enum_clickup_type_consulting.TASK), page)
tasks, err := service_clickup.ReturnTasks(list.Id, int(enum_clickup_type_ps_hierarchy.TASK), page)

if err != nil {
fmt.Println("Error VerifyTasks :: ", err.Error())
Expand Down Expand Up @@ -179,9 +180,9 @@ func VerifySubtask(list type_clickup.ListResponse, customFieldTypeConsulting int
}

if len(task.SubTasks) == 0 {
fmt.Println(enum_clickup_type_consulting.ToString(customFieldTypeConsulting),
fmt.Println(enum_clickup_type_ps_hierarchy.ToString(customFieldTypeConsulting),
" Without ",
enum_clickup_type_consulting.ToString(customFieldTypeConsultingSubTask),
enum_clickup_type_ps_hierarchy.ToString(customFieldTypeConsultingSubTask),
" :: ", variables_global.Customer.IntegrationName, " :: ", task.Name,
" :: ", strings.ToLower(task.Status.Status), " :: ", task.Url,
" :: ", service_clickup.RetAssigness(task.Assignees))
Expand All @@ -200,15 +201,15 @@ func VerifySubtask(list type_clickup.ListResponse, customFieldTypeConsulting int
// " :: ", service_clickup.RetAssigness(task.Assignees))
// }

if customFieldTypeConsulting == int(enum_clickup_type_consulting.STORE) && variables_global.Customer.CheckTagsValidationStory != "" {
if customFieldTypeConsulting == int(enum_clickup_type_ps_hierarchy.STORE) && variables_global.Customer.CheckTagsValidationStory != "" {
if !service_clickup.CheckTags(task.Tags, variables_global.Customer.CheckTagsValidationStory) {
fmt.Println("Story without TAGS", " :: ", variables_global.Customer.IntegrationName, " :: ", task.Name, " :: ",
strings.ToLower(task.Status.Status), " :: ", task.Url,
" :: ", service_clickup.RetAssigness(task.Assignees))

}

if task.CustomField.LinkConvisoPlatform == "" || !strings.Contains(task.CustomField.LinkConvisoPlatform, "/projects/") {
if task.CustomField.PSConvisoPlatformLink == "" || !strings.Contains(task.CustomField.PSConvisoPlatformLink, "/projects/") {
fmt.Println("Story without Conviso Platform URL: ", " :: ", variables_global.Customer.IntegrationName,
" :: ", task.Name, " :: ",
strings.ToLower(task.Status.Status), " :: ", task.Url,
Expand All @@ -229,9 +230,9 @@ func VerifySubtask(list type_clickup.ListResponse, customFieldTypeConsulting int
fmt.Println(
subTask.Name,
" should be ",
enum_clickup_type_consulting.ToString(customFieldTypeConsultingSubTask),
enum_clickup_type_ps_hierarchy.ToString(customFieldTypeConsultingSubTask),
" but is ",
enum_clickup_type_consulting.ToString(customFieldsSubTask),
enum_clickup_type_ps_hierarchy.ToString(customFieldsSubTask),
" :: ", variables_global.Customer.IntegrationName, " :: ",
subTask.Name, " :: ",
strings.ToLower(subTask.Status.Status),
Expand All @@ -249,12 +250,39 @@ func VerifySubtask(list type_clickup.ListResponse, customFieldTypeConsulting int

}

func ListStoryInProgress(list type_clickup.ListResponse) {
page := 0

for {
tasks, err := service_clickup.ReturnTasksByStatus(list.Id, enum_clickup_type_ps_hierarchy.STORE, enum_clickup_statuses.IN_PROGRESS, page)

if err != nil {
fmt.Println("Error ListStoryInProgress :: ", err.Error())
return
}

for i := 0; i < len(tasks.Tasks); i++ {
fmt.Println("Story In Progress",
" :: ", variables_global.Customer.IntegrationName,
" :: ", tasks.Tasks[i].Name,
" :: ", tasks.Tasks[i].Url,
" :: ", service_clickup.RetAssigness(tasks.Tasks[i].Assignees))
}

if tasks.LastPage {
break
}

page++
}
}

func UpdateProjectWithStore(list type_clickup.ListResponse) {
UpdateSubtask(list, enum_clickup_type_consulting.TASK, enum_clickup_type_consulting.STORE)
UpdateSubtask(list, enum_clickup_type_consulting.STORE, enum_clickup_type_consulting.EPIC)
UpdateTask(list, enum_clickup_type_ps_hierarchy.TASK, enum_clickup_type_ps_hierarchy.STORE)
UpdateTask(list, enum_clickup_type_ps_hierarchy.STORE, enum_clickup_type_ps_hierarchy.EPIC)
}

func UpdateSubtask(list type_clickup.ListResponse, typeConsultingTask int, typeConsultingParent int) {
func UpdateTask(list type_clickup.ListResponse, typeConsultingTask int, typeConsultingParent int) {
page := 0

for {
Expand Down Expand Up @@ -288,6 +316,14 @@ func UpdateSubtask(list type_clickup.ListResponse, typeConsultingTask int, typeC
continue
}

if taskParent.CustomField.PSProjectHierarchy != typeConsultingParent {
fmt.Println(
taskParent.Id, " :: ", taskParent.Name, " :: ", taskParent.Url,
" :: ", " isn't type ", enum_clickup_type_ps_hierarchy.ToString(typeConsultingParent),
)
continue
}

var requestTask type_clickup.TaskRequestStore
requestTask.Status = taskParent.Status.Status
requestTask.DueDate, _ = strconv.ParseInt(taskParent.DueDate, 10, 64)
Expand Down Expand Up @@ -328,10 +364,10 @@ func UpdateSubtask(list type_clickup.ListResponse, typeConsultingTask int, typeC
allTaskDone = false
}

if taskParent.CustomField.TypeConsulting == enum_clickup_type_consulting.STORE &&
taskParent.CustomField.LinkConvisoPlatform != "" && convisoPlatformProject.Id == "" {
if taskParent.CustomField.PSProjectHierarchy == enum_clickup_type_ps_hierarchy.STORE &&
taskParent.CustomField.PSConvisoPlatformLink != "" && convisoPlatformProject.Id == "" {

projectId, err := service_conviso_platform.RetProjectIdCustomField(taskParent.CustomField.LinkConvisoPlatform)
projectId, err := service_conviso_platform.RetProjectIdCustomField(taskParent.CustomField.PSConvisoPlatformLink)

if err == nil {
convisoPlatformProject, err = service_conviso_platform.GetProject(projectId)
Expand Down Expand Up @@ -378,7 +414,7 @@ func UpdateSubtask(list type_clickup.ListResponse, typeConsultingTask int, typeC
}
}

func UpdateClickUpConvisoPlatform(justVerify bool) {
func MainAction(mainAction int) {
fmt.Println("...Starting ClickUp Automation...")

for i := 0; i < len(variables_global.Config.Integrations); i++ {
Expand All @@ -395,15 +431,15 @@ func UpdateClickUpConvisoPlatform(justVerify bool) {

variables_global.Customer = variables_global.Config.Integrations[i]

if justVerify {
switch mainAction {
case enum_main_action.TASKS_VERIFY:
VerifyErrorsProjectWithStore(list)
//return
}

if !justVerify {
case enum_main_action.TASKS_UPDATE:
UpdateProjectWithStore(list)
//return
case enum_main_action.TASKS_INPROGRESS:
ListStoryInProgress(list)
}

fmt.Println("Finish: ", time.Now().Format("2006-01-02 15:04:05"))
}

Expand All @@ -425,7 +461,6 @@ func MenuSearchConvisoPlatform() {
}
switch input {
case 0:
break
case 1:
service_conviso_platform.InputSearchRequimentsPlatform()
case 2:
Expand Down Expand Up @@ -539,7 +574,7 @@ func CreateProject() {

customFieldPSHierarchy := type_clickup.CustomFieldRequest{
variables_constant.CLICKUP_CUSTOM_FIELD_PS_HIERARCHY,
strconv.Itoa(enum_clickup_type_consulting.STORE),
strconv.Itoa(enum_clickup_type_ps_hierarchy.STORE),
}

customFieldPSTeam := type_clickup.CustomFieldRequest{
Expand Down Expand Up @@ -606,7 +641,7 @@ func CreateProject() {

customFieldTypeConsultingSubTask := type_clickup.CustomFieldRequest{
variables_constant.CLICKUP_CUSTOM_FIELD_PS_HIERARCHY,
strconv.Itoa(enum_clickup_type_consulting.TASK),
strconv.Itoa(enum_clickup_type_ps_hierarchy.TASK),
}

customFieldsSubTask := []type_clickup.CustomFieldRequest{
Expand Down Expand Up @@ -685,13 +720,9 @@ func main() {

SetDefaultValue()

//service_clickup.RetCustomFieldCustomerPosition()

// fmt.Println(variables_constant.CLICKUP_TOKEN_NAME + " " + os.Getenv(variables_constant.CLICKUP_TOKEN_NAME))
// fmt.Println(variables_constant.CONVISO_PLATFORM_TOKEN_NAME + " " + os.Getenv(variables_constant.CONVISO_PLATFORM_TOKEN_NAME))

integrationJustVerify := flag.Bool("iv", false, "Verify if clickup tasks is ok")
integrationUpdateTasks := flag.Bool("iu", false, "Update Conviso Platform and ClickUp Tasks")
integrationJustVerify := flag.Bool("tv", false, "Verify if clickup tasks is ok")
integrationUpdateTasks := flag.Bool("tu", false, "Update Conviso Platform and ClickUp Tasks")
integrationListTasksInProgress := flag.Bool("tsip", false, "List Clickup Stories In Progress")
deploy := flag.Bool("d", false, "See info about deploys")
version := flag.Bool("v", false, "Script Version")

Expand All @@ -705,12 +736,17 @@ func main() {
flag.Parse()

if *integrationJustVerify {
UpdateClickUpConvisoPlatform(true)
MainAction(enum_main_action.TASKS_VERIFY)
os.Exit(0)
}

if *integrationUpdateTasks {
UpdateClickUpConvisoPlatform(false)
MainAction(enum_main_action.TASKS_UPDATE)
os.Exit(0)
}

if *integrationListTasksInProgress {
MainAction(enum_main_action.TASKS_INPROGRESS)
os.Exit(0)
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 02ce926

Please sign in to comment.