Skip to content

Commit

Permalink
add time entries job
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Oct 31, 2023
1 parent 6fe7fe0 commit d81a711
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/services/team_maker_project_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def call

def create_time_entires!(team_maker_project_time_entries)
team_maker_project_time_entries.each do |time_entry|
next if User.find_by(email: time_entry.resource).nil?

user = User.find_by(email: time_entry.resource)
next if user.nil?

TimeEntry.create!(
statement_of_work:,
Expand All @@ -42,11 +41,11 @@ def create_requirements!(team_maker_project_requirements)

def create_assignments!(team_maker_project_assignments, requirement)
team_maker_project_assignments.each do |assignment|
next if User.find_by(email: assignment.resource).nil?
user = User.find_by(email: assignment.resource)

Assignment.create!(
requirement:,
user: User.find_by(email: assignment.resource),
user:,
start_date: assignment.starts_on,
end_date: assignment.ends_on,
coverage: assignment.coverage
Expand All @@ -68,7 +67,7 @@ def professions
@professions ||= {
'Engineering' => Profession.find_by(name: 'Engineer'),
'Project Management' => Profession.find_by(name: 'Project Manager'),
'Designer' => Profession.find_by(name: 'Design')
'Design' => Profession.find_by(name: 'Designer')
}
end

Expand Down
9 changes: 9 additions & 0 deletions app/sidekiq/time_entries_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class TimeEntriesJob
include Sidekiq::Job

def perform(*_args)
CreateTimeEntriesTask.create!
end
end
11 changes: 11 additions & 0 deletions app/tasks/create_time_entries_task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class CreateTimeEntriesTask
def self.create!
projects = Project.all

projects.each do |project|
TeamMakerProjectCreator.new(project).call
end
end
end
6 changes: 6 additions & 0 deletions config/sidekiq_cron_scheduler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ syncronize_issues:
cron: "every 1 hour"
class: "IssuesJob"
queue: default

syncronize_time_entries:
name: issues_job, # must be uniq!
cron: "every 5 minutes"
class: "TimeEntriesJob"
queue: default

0 comments on commit d81a711

Please sign in to comment.