graph2: Added importLog query and associated models and repository functions.
the build was successful
the build was successful
This commit is contained in:
@@ -18,14 +18,14 @@ type ParsedLog struct {
|
||||
}
|
||||
|
||||
// ParseLogs parses the logs from the data.
|
||||
func ParseLogs(data string) ([]ParsedLog, error) {
|
||||
func ParseLogs(data string, tz *time.Location) ([]ParsedLog, error) {
|
||||
metadata := ParseMetadata(data)
|
||||
results := make([]ParsedLog, 0, len(metadata["Date"]))
|
||||
scanner := bufio.NewScanner(strings.NewReader(data))
|
||||
|
||||
for i, dateStr := range metadata["Date"] {
|
||||
// Parse date
|
||||
date, err := time.Parse("January 2, 2006", dateStr)
|
||||
date, err := time.ParseInLocation("January 2, 2006", dateStr, tz)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to parse date #%d: %#+v is not the in the correct format of \"January 2, 2006\"", i+1, dateStr)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParseLogs(t *testing.T) {
|
||||
results, err := forumlog.ParseLogs(testLog)
|
||||
results, err := forumlog.ParseLogs(testLog, time.UTC)
|
||||
if err != nil {
|
||||
t.Fatalf("Parse: %s", err)
|
||||
}
|
||||
@@ -23,9 +23,9 @@ func TestParseLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseLogsErrors(t *testing.T) {
|
||||
_, err1 := forumlog.ParseLogs(brokenLogNoPosts)
|
||||
_, err2 := forumlog.ParseLogs(brokenLogBrokenPost)
|
||||
_, err3 := forumlog.ParseLogs(brokenLogBrokenDate)
|
||||
_, err1 := forumlog.ParseLogs(brokenLogNoPosts, time.UTC)
|
||||
_, err2 := forumlog.ParseLogs(brokenLogBrokenPost, time.UTC)
|
||||
_, err3 := forumlog.ParseLogs(brokenLogBrokenDate, time.UTC)
|
||||
|
||||
t.Log("Should be about no posts:", err1)
|
||||
t.Log("Should be about a broken post:", err2)
|
||||
|
||||
Reference in New Issue
Block a user