Skip to content

Instantly share code, notes, and snippets.

@alagu
Last active July 15, 2024 11:21
Show Gist options
  • Save alagu/1422f9e493ede9afecb51eab26e1725a to your computer and use it in GitHub Desktop.
Save alagu/1422f9e493ede9afecb51eab26e1725a to your computer and use it in GitHub Desktop.
amf_goals_delete
emails = %w(user@example.com)
e = User.where(email: emails).map(&:employee)
g = Goal.joins(:employee_goals).where(employee_goals: {employee: e})
ga = GoalActivity.where(goal: g, activity_type: [:comment, :progress_checkin])
gp = GoalProgress.where(goal: g)
ga.map(&:discard)
gp.update(progress_status: "not_started", current_progress: 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment