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

@ -26,7 +26,7 @@ func NewDBConnection() *DBConnector {
} }
func (c *DBConnector) CreateTables() { 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 { for _, scriptName := range tableCreationScripts {
c.ExecuteSqlScript(InsightDatabaseName, scriptName) c.ExecuteSqlScript(InsightDatabaseName, scriptName)
@ -51,8 +51,8 @@ func (c *DBConnector) UpdateTimeEntries(entries *[]*TimeEntry) {
ent.BillableHoursFormattedString, ent.BillableHoursFormattedString,
ent.BillableTimeString, ent.BillableTimeString,
ent.BillableTotal, ent.BillableTotal,
ent.Date, ent.TimeEntryDate,
ent.Description, ent.TimeEntryDescription,
ent.ProjectId, ent.ProjectId,
ent.RateBill, ent.RateBill,
ent.RateBurden, ent.RateBurden,
@ -103,6 +103,25 @@ func (c *DBConnector) FetchUsers() *[]*User {
return &ret 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) { func (c *DBConnector) ExecuteSqlScript(database string, scriptName string) {
db := c.checkoutConnection(database) db := c.checkoutConnection(database)
defer c.returnConnection(db) defer c.returnConnection(db)

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

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

Loading…
Cancel
Save