|
|
|
|
@ -26,7 +26,7 @@ func NewDBConnection() *DBConnector {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *DBConnector) CreateTables() {
|
|
|
|
|
tableCreationScripts := []string{"create-user-table.sql", "create-timeentry-table.sql"}
|
|
|
|
|
tableCreationScripts := []string{"create-insight-user-table.sql", "create-timeentry-table.sql"}
|
|
|
|
|
|
|
|
|
|
for _, scriptName := range tableCreationScripts {
|
|
|
|
|
c.ExecuteSqlScript(InsightDatabaseName, scriptName)
|
|
|
|
|
@ -51,8 +51,8 @@ func (c *DBConnector) UpdateTimeEntries(entries *[]*TimeEntry) {
|
|
|
|
|
ent.BillableHoursFormattedString,
|
|
|
|
|
ent.BillableTimeString,
|
|
|
|
|
ent.BillableTotal,
|
|
|
|
|
ent.Date,
|
|
|
|
|
ent.Description,
|
|
|
|
|
ent.TimeEntryDate,
|
|
|
|
|
ent.TimeEntryDescription,
|
|
|
|
|
ent.ProjectId,
|
|
|
|
|
ent.RateBill,
|
|
|
|
|
ent.RateBurden,
|
|
|
|
|
@ -103,6 +103,25 @@ func (c *DBConnector) FetchUsers() *[]*User {
|
|
|
|
|
return &ret
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *DBConnector) FetchEngineerUsers() *[]*User {
|
|
|
|
|
ret := make([]*User, 0, 50)
|
|
|
|
|
cx := c.checkoutConnection(InsightDatabaseName)
|
|
|
|
|
queryText := "SELECT insight.users.Id, insight.users.FirstName, insight.users.LastName, insight.users.EmailAddress FROM insight.users INNER JOIN projects.users on insight.users.EmailAddress = projects.users.email where projects.users.priv & POW(2, 25) > 0;"
|
|
|
|
|
rs, err := cx.Query(queryText)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalln(err)
|
|
|
|
|
}
|
|
|
|
|
for rs.Next() {
|
|
|
|
|
u := User{}
|
|
|
|
|
err := rs.Scan(&u.Id, &u.FirstName, &u.LastName, &u.EmailAddress)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalln(err)
|
|
|
|
|
}
|
|
|
|
|
ret = append(ret, &u)
|
|
|
|
|
}
|
|
|
|
|
return &ret
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *DBConnector) ExecuteSqlScript(database string, scriptName string) {
|
|
|
|
|
db := c.checkoutConnection(database)
|
|
|
|
|
defer c.returnConnection(db)
|
|
|
|
|
|