we have the first round of engineering time from insight in the reports

master
dtookey 4 years ago
parent 49e6b7bb73
commit accade8dff

@ -87,8 +87,8 @@ type (
BillableHoursFormattedString string
BillableTimeString string
BillableTotal float64
Date string
Description string
TimeEntryDate string `json:"Date,omitempty"`
TimeEntryDescription string `json:"Description,omitempty"`
ProjectId string `json:"Project_Id,omitempty"`
RateBill float64
RateBurden float64
@ -127,7 +127,7 @@ func (ic *Interconnect) UpdateUsers() {
}
func (ic *Interconnect) UpdateTimeEntries() {
users := ic.DBConnector.FetchUsers()
users := ic.DBConnector.FetchEngineerUsers()
for _, userPtr := range *users {
user := *userPtr
entries := ic.Client.GetTimeAllTimeEntriesForUserThroughDate(user.Id, "2022-04-28")

@ -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)

@ -10,8 +10,8 @@ CREATE TABLE insight.timeentry
BillableHoursFormattedString VARCHAR(30),
BillableTimeString VARCHAR(30),
BillableTotal REAL,
Date VARCHAR(30),
Description VARCHAR(4096),
TimeEntryDate VARCHAR(30),
TimeEntryDescription VARCHAR(4096),
ProjectId VARCHAR(50),
RateBill REAL,
RateBurden REAL,

@ -6,8 +6,8 @@ INSERT INTO insight.timeentry (ActualHours,
BillableHoursFormattedString,
BillableTimeString,
BillableTotal,
Date,
Description,
TimeEntryDate,
TimeEntryDescription,
ProjectId,
RateBill,
RateBurden,

Loading…
Cancel
Save