MCPcopy Create free account
hub / github.com/GitbookIO/micro-analytics / timeRangeToInt

Function timeRangeToInt

database/sqlite/sharded.go:621–646  ·  view source on GitHub ↗

Helper function to return start and end time as an int in YYYYMM format Defaults to 0 for Start and 999999 for End

(timeRange *database.TimeRange)

Source from the content-addressed store, hash-verified

619// Helper function to return start and end time as an int in YYYYMM format
620// Defaults to 0 for Start and 999999 for End
621func timeRangeToInt(timeRange *database.TimeRange) (int, int) {
622 var err error
623 layout := "200601"
624
625 startDefault := 0
626 startInt := 0
627 endDefault := 999999
628 endInt := 999999
629
630 if timeRange != nil {
631 if !timeRange.Start.Equal(time.Time{}) {
632 startInt, err = strconv.Atoi(timeRange.Start.Format(layout))
633 if err != nil {
634 startInt = startDefault
635 }
636 }
637 if !timeRange.End.Equal(time.Time{}) {
638 endInt, err = strconv.Atoi(timeRange.End.Format(layout))
639 if err != nil {
640 endInt = endDefault
641 }
642 }
643 }
644
645 return startInt, endInt
646}
647
648// Format URL for a specific shard
649// Basically, remove start/end if is is before/after shard time

Callers 4

QueryMethod · 0.85
CountMethod · 0.85
GroupByMethod · 0.85
SeriesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected