-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # Gemfile.lock
- Loading branch information
Showing
33 changed files
with
583 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Eyeloupe | ||
class JobsController < ApplicationController | ||
include Searchable | ||
|
||
before_action :set_job, only: %i[ show ] | ||
|
||
def index | ||
@pagy, @jobs = pagy(@query, items: 50) | ||
|
||
render partial: 'frame' if params[:frame].present? | ||
end | ||
|
||
def show | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_job | ||
@job = Job.find(params[:id]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Eyeloupe | ||
module JobsHelper | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Eyeloupe | ||
module RequestHelper | ||
# @param [Eyeloupe::InRequest, Eyeloupe::OutRequest] request The request object | ||
# @return [String] The formatted response | ||
def format_response(request) | ||
type = request.format.to_s != '*/*' ? request.format.to_s : request&.headers | ||
format(type, request.response) | ||
end | ||
|
||
# @param [Eyeloupe::InRequest, Eyeloupe::OutRequest] request The request object | ||
# @return [String] The formatted payload | ||
def format_payload(request) | ||
type = request.format.to_s != '*/*' ? request.format.to_s : request&.headers | ||
format(type, request.payload) | ||
end | ||
|
||
private | ||
|
||
def format(format, str) | ||
case format | ||
when /json/ | ||
JSON.pretty_generate(JSON.parse(str || '{}')) | ||
when /xml/ | ||
Nokogiri::XML(str || '<></>').to_xml(indent: 2) | ||
else | ||
str | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Eyeloupe | ||
class Job < ApplicationRecord | ||
validates :job_id, uniqueness: true | ||
|
||
enum status: [:enqueued, :running, :completed, :failed, :discarded] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<%= turbo_frame_tag "frame" do %> | ||
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | ||
<div class="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8"> | ||
|
||
<table class="min-w-full divide-y divide-gray-300"> | ||
<thead> | ||
<tr> | ||
<th scope="col" class="py-3 pl-4 pr-3 text-left text-sm font-medium uppercase tracking-wide text-gray-500 sm:pl-0">Name</th> | ||
<th scope="col" class="px-3 py-3 text-left text-sm font-medium uppercase tracking-wide text-gray-500">Queue</th> | ||
<th scope="col" class="px-3 py-3 text-left text-sm font-medium uppercase tracking-wide text-gray-500">Adapter</th> | ||
<th scope="col" class="px-3 py-3 text-left text-sm font-medium uppercase tracking-wide text-gray-500">Status</th> | ||
<th scope="col" class="px-3 py-3 text-left text-sm font-medium uppercase tracking-wide text-gray-500">Retry</th> | ||
<th scope="col" class="px-3 py-3 text-left text-sm font-medium uppercase tracking-wide text-gray-500">Enqueued at</th> | ||
<th scope="col" class="relative py-3 pl-3 pr-4 sm:pr-0"> | ||
<span class="sr-only">Details</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody class="divide-y divide-gray-200"> | ||
<% @jobs.each do |job| %> | ||
<tr> | ||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-base font-medium text-gray-900 sm:pl-0"> | ||
<%= job.classname %> | ||
</td> | ||
<td class="whitespace-nowrap px-3 py-4 text-base text-gray-500"><%= job.queue_name %></td> | ||
<td class="whitespace-nowrap px-3 py-4 text-base text-gray-500"><%= job.adapter %></td> | ||
<td class="whitespace-nowrap px-3 py-4 text-base text-gray-500"> | ||
<%= render "eyeloupe/shared/job_status", job: job %> | ||
</td> | ||
<td class="whitespace-nowrap px-3 py-4 text-base text-gray-500"><%= job.retry %></td> | ||
<td class="whitespace-nowrap px-3 py-4 text-base text-gray-500"><%= distance_of_time_in_words(job.created_at, DateTime.now) %></td> | ||
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-base font-medium sm:pr-0"> | ||
<%= link_to "Details", job_path(job), class: "text-gray-600 hover:text-gray-900", data: {"turbo_frame": "_top"} %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<aside class="mt-4 px-4 py-3 flex items-center justify-center sm:px-6" aria-label="Pagination"> | ||
<div class="flex-1 flex justify-center"> | ||
<%== pagy_nav(@pagy) %> | ||
</div> | ||
</aside> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div data-controller="eyeloupe--search" class="px-4 sm:px-6 lg:px-8 bg-white rounded-md shadow-md py-5"> | ||
<div class="sm:flex sm:items-center"> | ||
<div class="sm:flex-auto"> | ||
<h1 class="text-xl font-semibold leading-6 text-gray-900">Jobs</h1> | ||
<p class="mt-2 text-sm text-gray-700">All jobs running in your application</p> | ||
</div> | ||
<div> | ||
<form method="get" data-action="eyeloupe--search#submit"> | ||
<input type="hidden" name="frame" value="frame" /> | ||
<label for="q" class="sr-only">Search</label> | ||
<input type="text" id="q" name="q" value="<%= params[:q] %>" placeholder="Search for job class" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-red-500 focus:border-red-500 sm:text-sm" /> | ||
</form> | ||
</div> | ||
</div> | ||
<div class="mt-8 flow-root"> | ||
<%= turbo_frame_tag "frame", src: jobs_path(frame: true), data: {"eyeloupe--refresh-target": "frame", "eyeloupe--search-target": "frame"} do %><% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<div class="px-4 sm:px-6 lg:px-8 bg-white rounded-md shadow-md py-5"> | ||
<div class="px-4 sm:px-0"> | ||
<h3 class="text-xl font-semibold leading-7 text-gray-900">Job details</h3> | ||
</div> | ||
<div class="mt-6 border-t border-gray-100"> | ||
<dl class="divide-y divide-gray-100"> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Enqueued at</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"> | ||
<%= @job.created_at.to_formatted_s(:long) %> (<%= distance_of_time_in_words(@job.created_at, DateTime.now) %>) | ||
</dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Duration</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"> | ||
<%= (@job.completed_at - @job.created_at).round %> seconds | ||
</dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Name</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"><%= @job.classname %></dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Adapter</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"> | ||
<%= @job.adapter %> | ||
</dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Queue</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"><%= @job.queue_name %></dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Job ID</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"> | ||
<%= @job.job_id %> | ||
</dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Retry</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"> | ||
<%= @job.retry %> | ||
</dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Status</dt> | ||
<dd class="mt-1 text-base leading-6 text-gray-700 sm:col-span-2 sm:mt-0"> | ||
<%= render "eyeloupe/shared/job_status", job: @job %> | ||
</dd> | ||
</div> | ||
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0"> | ||
<dt class="text-base font-medium leading-6 text-gray-900">Arguments</dt> | ||
<dd class="mt-1 text-base leading-6 sm:col-span-2 sm:mt-0 rounded-md bg-black text-white overflow-x-auto"> | ||
<% if @job.args.present? %> | ||
<pre class="p-2"><%= JSON.pretty_generate(JSON.parse(@job.args || "{}")) %></pre> | ||
<% else %> | ||
<p class="text-gray-400 p-2">No args</p> | ||
<% end %> | ||
</dd> | ||
</div> | ||
</dl> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.