Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for async activities export #43

Merged
merged 8 commits into from
Jul 19, 2021

Conversation

tommycarney
Copy link

@tommycarney tommycarney commented Jul 13, 2021

This PR provides support for a new async activities export with optional params for start date, end date and activity type.

	activities_export, err := api.MetricsCreateActivitiesExport(&NewMetricsActivitiesExport{
		StartDate: "2020-01-01",
		EndDate:   "2020-12-31",
		Type:      "contraction",
	})

Initially, the export will have the status pending and a nil file_url. After a period of time, the async job will complete and the status will update to processing and then succeeded or failed. In the case of succeeded, the file_url will be populated with the url with the zipped activities export.

A user of the client library could schedule a job with the ID of the export, so they can periodically check it until it reaches succeeded or failed.

If you have the uuid of the export, you can retrieve it via:

var activities_export_id = "7f554dba-4a41-4cb2-9790-2045e4c3a5b1"
activities_export, err := api.MetricsRetrieveActivitiesExport(activities_export_id)

@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #32313: Go async export.

@tommycarney tommycarney changed the title Async activities export [WIP] Implement support for async activities export Jul 14, 2021
}

// NewMetricsActivitiesExport is the POST-ed to create a MetricsActivitiesExport .
type NewMetricsActivitiesExport struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to avoid struct name starting with New. You can use CreateMetricsActivitiesExportParam.

metrics_activities_exports.go Show resolved Hide resolved
metrics_activities_exports.go Show resolved Hide resolved
metrics_activities_exports.go Show resolved Hide resolved
AccountToken: "token",
AccessKey: "key",
}
activities_export, err := tested.MetricsCreateActivitiesExport(&NewMetricsActivitiesExport{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use underscores in Go names; var activities_export should be activitiesExport

@@ -0,0 +1,51 @@
package chartmogul
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code does not pass gofmt in 1 place. Go fmt your code!

May be some whitespace issue. Try formatting with gofmt.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, done!

AccessKey: "key",
}

var activitiesExportId = "7f554dba-4a41-4cb2-9790-2045e4c3a5b1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var activitiesExportId = "7f554dba-4a41-4cb2-9790-2045e4c3a5b1"
var activitiesExportID = "7f554dba-4a41-4cb2-9790-2045e4c3a5b1"

@tommycarney tommycarney merged commit f2b67b0 into main Jul 19, 2021
@tommycarney tommycarney deleted the tc/ch32313/async-activities-export branch July 19, 2021 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants