Skip to content

Create Cron-Job for fetching contributions from gh archive dataset on bigquery #21

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

Open
wants to merge 4 commits into
base: feat/contribution-service
Choose a base branch
from

Conversation

VishakhaSainani-Josh
Copy link
Collaborator

  1. Create cronjob for fetching and processing contributions from gh archive dataset available on bigquery scheduled everyday at 1 am IST.
  2. This cron job fetches all the contributions made by the users on the platform on previous day.
  3. Then Process those contributions and save them in the db.
  4. Also remove the handler- FetchUsersLatestContributions made for testing the ProcessFetchContributions service, as this is build as a cronjob.

…a cron job that is scheduled everyday at 1 am IST
…essfetchcontributions service. As this will be a cronjob
…ecessary auth and user service from dependencies
Comment on lines 17 to 26
func (c *CronJob) Execute(ctx context.Context, fn func(context.Context)) func() {
return func() {
slog.Info("cron job started at", "time ", time.Now())
defer func() {
slog.Info("cron job completed")
}()

fn(ctx)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you try below

func (c *CronJob) Execute(ctx context.Context, fn func(context.Context)) {
	slog.Info("cron job started at", "time ", time.Now())
	defer func() {
		slog.Info("cron job completed")
	}()

	fn(ctx)
}

and when using it

	_, err := s.cron.AddFunc("0 1 * * *", func() { d.Execute(context.Background(), d.run) })

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay

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.

3 participants