Skip to content

Commit

Permalink
Merge pull request #1090 from wakatime/bugfix/url-type
Browse files Browse the repository at this point in the history
Add missing entity type url and event
  • Loading branch information
alanhamlett authored Sep 14, 2024
2 parents f231541 + c82e6c3 commit 90e66e8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func setFlags(cmd *cobra.Command, v *viper.Viper) {
flags.String(
"entity-type",
"",
"Entity type for this heartbeat. Can be \"file\", \"domain\" or \"app\". Defaults to \"file\".",
"Entity type for this heartbeat. Can be \"file\", \"domain\", \"url\", or \"app\". Defaults to \"file\".",
)
flags.StringSlice(
"exclude",
Expand Down
14 changes: 14 additions & 0 deletions pkg/heartbeat/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ const (
FileType EntityType = iota
// DomainType represents a domain entity.
DomainType
// UrlType represents a url entity without the url params.

Check warning on line 16 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests

exported: comment on exported const URLType should be of the form "URLType ..." (revive)

Check warning on line 16 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

exported: comment on exported const URLType should be of the form "URLType ..." (revive)

Check warning on line 16 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests Windows

exported: comment on exported const URLType should be of the form "URLType ..." (revive)

Check warning on line 16 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests

exported: comment on exported const URLType should be of the form "URLType ..." (revive)

Check warning on line 16 in pkg/heartbeat/entity.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

exported: comment on exported const URLType should be of the form "URLType ..." (revive)
URLType
// EventType represents a meeting or calendar event.
EventType
// AppType represents an app entity.
AppType
)

const (
fileTypeString = "file"
domainTypeString = "domain"
urlTypeString = "url"
eventTypeString = "event"
appTypeString = "app"
)

Expand All @@ -30,6 +36,10 @@ func ParseEntityType(s string) (EntityType, error) {
return FileType, nil
case domainTypeString:
return DomainType, nil
case urlTypeString:
return URLType, nil
case eventTypeString:
return EventType, nil
case appTypeString:
return AppType, nil
default:
Expand Down Expand Up @@ -68,6 +78,10 @@ func (t EntityType) String() string {
return fileTypeString
case DomainType:
return domainTypeString
case URLType:
return urlTypeString
case EventType:
return eventTypeString
case AppType:
return appTypeString
default:
Expand Down
2 changes: 2 additions & 0 deletions pkg/heartbeat/entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func typeTests() map[string]heartbeat.EntityType {
return map[string]heartbeat.EntityType{
"file": heartbeat.FileType,
"domain": heartbeat.DomainType,
"url": heartbeat.URLType,
"event": heartbeat.EventType,
"app": heartbeat.AppType,
}
}
Expand Down

0 comments on commit 90e66e8

Please sign in to comment.