<commit_before>package falconPortal

import (
	"fmt"
	"time"

	"github.com/Cepave/fe/model/uic"
	"github.com/astaxie/beego/orm"
)

func CloseEvent(username string, colsed_note string, id string) (err error) {
	q := orm.NewOrm()
	q.Using("falcon_portal")
	userid := uic.ReadUserIdByName(username)
	_, err = q.Raw("Update event_cases SET user_modified = ?, closed_at = ?, status = ?, closed_note = ? WHERE id = ?", userid, time.Now(), "SOLVED", colsed_note, id).Exec()
	return
}

func AddNote(username string, note string, id string, status string, caseId string) (err error) {
	q := orm.NewOrm()
	q.Using("falcon_portal")
	userid := uic.ReadUserIdByName(username)
	sqlbase := fmt.Sprintf("SET event_caseId = '%s' , user_id = %d", id, userid)
	if note != "" {
		sqlbase = fmt.Sprintf("%s , note = '%s'", sqlbase, note)
	}
	if status != "" {
		sqlbase = fmt.Sprintf("%s, status = '%s'", sqlbase, status)
		if status == "Sovled" {
			CloseEvent(username, note, id)
		}
	}
	//for set boss case id
	if caseId != "" {
		sqlbase = fmt.Sprintf("%s, case_id = '%s'", sqlbase, caseId)
	}
	_, err = q.Raw(fmt.Sprintf("Insert INTO event_note %s, timestamp = ?", sqlbase), time.Now()).Exec()
	return
}
<commit_msg>modified code for saving process info into event_cases<commit_after>package falconPortal

import (
	"fmt"
	"time"

	"github.com/Cepave/fe/model/uic"
	"github.com/astaxie/beego/orm"
)

func CloseEvent(username string, colsed_note string, id string) (err error) {
	q := orm.NewOrm()
	q.Using("falcon_portal")
	userid := uic.ReadUserIdByName(username)
	_, err = q.Raw("Update event_cases SET user_modified = ?, closed_at = ?, status = ?, closed_note = ? WHERE id = ?", userid, time.Now(), "SOLVED", colsed_note, id).Exec()
	return
}

func UpdateProcess(processNoteID int, processStatus string, id string) (err error) {
	q := orm.NewOrm()
	q.Using("falcon_portal")
	_, err = q.Raw("Update event_cases SET process_note = ?, process_status = ? WHERE id = ?", processNoteID, processStatus, id).Exec()
	return
}

func AddNote(username string, note string, id string, status string, caseId string) (err error) {
	q := orm.NewOrm()
	q.Using("falcon_portal")
	userid := uic.ReadUserIdByName(username)
	sqlbase := fmt.Sprintf("SET event_caseId = %s , user_id = %d, timestamp = %v", id, userid, time.Now())
	if note != "" {
		sqlbase = fmt.Sprintf("%s , note = '%s'", sqlbase, note)
	}
	if status != "" {
		sqlbase = fmt.Sprintf("%s, status = '%s'", sqlbase, status)
	}
	//for set boss case id
	if caseId != "" {
		sqlbase = fmt.Sprintf("%s, case_id = '%s'", sqlbase, caseId)
	}
	var eventNote EventNote
	q.Raw(fmt.Sprintf("Insert INTO event_note %s", sqlbase)).QueryRow(&eventNote)

	if eventNote.Status == "Sovled" || eventNote.Status == "In Process" {
		err = UpdateProcess(eventNote.Id, eventNote.Status, id)
	}
	return
}

{'fraction_non_alphanumeric': 0.16779239246356203, 'fraction_numerical': 0.0, 'mean_word_length': 4.474708171206226, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3420020', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1050, 'n_words': 252}