Skip to content

Commit

Permalink
[api] Use PROJECT_CLASSES & PACKAGE_CLASSES
Browse files Browse the repository at this point in the history
Use the new `Event` contasts with the events related to `Project` and
`Package` in `project_log_rotate_manually.rake` and
`delayed_job_stats.rb`. This makes the code more readable und make it easy to
understand.
  • Loading branch information
Ana06 committed Dec 11, 2017
1 parent ecfb04c commit 676f495
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
20 changes: 1 addition & 19 deletions src/api/lib/tasks/project_log_rotate_manually.rake
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
desc 'Run project log rotate job manually'
task :project_log_rotate_manually do
# Package and Project events
event_types = ["Event::BranchCommand",
"Event::Build",
"Event::CommentForPackage",
"Event::Commit",
"Event::CreatePackage",
"Event::DeletePackage",
"Event::ServiceFail",
"Event::ServiceSuccess",
"Event::UndeletePackage",
"Event::UpdatePackage",
"Event::Upload",
"Event::VersionChange",
"Event::CommentForProject",
"Event::CreateProject",
"Event::DeleteProject",
"Event::UndeleteProject",
"Event::UpdateProjectConfig",
"Event::UpdateProject"]
event_types = Event::PROJECT_CLASSES | Event::PACKAGE_CLASSES
oldest_date = 10.days.ago

# First, skip old events and mark them all as "logged" (even those that
Expand Down
20 changes: 1 addition & 19 deletions src/api/script/delayed_job_stats.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
puts "-----------EVENT-STATS------------"
# Package and Project events
event_types = ["Event::BranchCommand",
"Event::Build",
"Event::CommentForPackage",
"Event::Commit",
"Event::CreatePackage",
"Event::DeletePackage",
"Event::ServiceFail",
"Event::ServiceSuccess",
"Event::UndeletePackage",
"Event::UpdatePackage",
"Event::Upload",
"Event::VersionChange",
"Event::CommentForProject",
"Event::CreateProject",
"Event::DeleteProject",
"Event::UndeleteProject",
"Event::UpdateProjectConfig",
"Event::UpdateProject"]
Event::PROJECT_CLASSES | Event::PACKAGE_CLASSES
oldest_date = 10.days.ago
project_logged = Event::Base.where(project_logged: false, eventtype: event_types).where(["created_at > ?", oldest_date]).count
mails_sent = Event::Base.where(mails_sent: false).count
Expand Down

0 comments on commit 676f495

Please sign in to comment.