GetProjectIdFromName -> GetIdFromName

This commit is contained in:
マリウス 2020-10-17 13:14:58 +01:00
parent 798af1a486
commit ee1ab3204b
No known key found for this signature in database
GPG key ID: C228EF0A530AF06F
3 changed files with 4 additions and 4 deletions

View file

@ -44,7 +44,7 @@ func NewCalendar(entries []Entry) (Calendar, error) {
sameDayHours := decimal.NewFromInt(0) sameDayHours := decimal.NewFromInt(0)
nextDayHours := decimal.NewFromInt(0) nextDayHours := decimal.NewFromInt(0)
projectId := GetProjectIdFromName(entry.Project) projectId := GetIdFromName(entry.Project)
if projects[projectId].Name == "" { if projects[projectId].Name == "" {
project, err := database.GetProject(entry.User, entry.Project) project, err := database.GetProject(entry.User, entry.Project)

View file

@ -229,7 +229,7 @@ func (database *Database) UpdateProject(user string, projectName string, project
return jsonerr return jsonerr
} }
projectId := GetProjectIdFromName(projectName) projectId := GetIdFromName(projectName)
dberr := database.DB.Update(func(tx *buntdb.Tx) error { dberr := database.DB.Update(func(tx *buntdb.Tx) error {
_, _, sperr := tx.Set(user + ":project:" + projectId, string(projectJson), nil) _, _, sperr := tx.Set(user + ":project:" + projectId, string(projectJson), nil)
@ -245,7 +245,7 @@ func (database *Database) UpdateProject(user string, projectName string, project
func (database *Database) GetProject(user string, projectName string) (Project, error) { func (database *Database) GetProject(user string, projectName string) (Project, error) {
var project Project var project Project
projectId := GetProjectIdFromName(projectName) projectId := GetIdFromName(projectName)
dberr := database.DB.View(func(tx *buntdb.Tx) error { dberr := database.DB.View(func(tx *buntdb.Tx) error {
value, err := tx.Get(user + ":project:" + projectId, false) value, err := tx.Get(user + ":project:" + projectId, false)

View file

@ -102,7 +102,7 @@ func ParseTime(timeStr string) (time.Time, error) {
} }
} }
func GetProjectIdFromName(projectName string) string { func GetIdFromName(projectName string) string {
reg, regerr := regexp.Compile("[^a-zA-Z0-9]+") reg, regerr := regexp.Compile("[^a-zA-Z0-9]+")
if regerr != nil { if regerr != nil {
return "" return ""