-
Notifications
You must be signed in to change notification settings - Fork 0
Island rhythms/task visualizer #64
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
IslandRhythms
wants to merge
29
commits into
main
Choose a base branch
from
IslandRhythms/task-visualizer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
296417f
begin tasks + fix authorized views
IslandRhythms d725ccc
link to npm if no task package
IslandRhythms 4c8f9dc
Merge branch 'main' into IslandRhythms/task-visualizer
IslandRhythms 5bbc944
v1 task overview
IslandRhythms d32696c
remove task creator for v1
IslandRhythms 3d920a0
Merge branch 'main' into IslandRhythms/task-visualizer
vkarpov15 9ddb57c
make requested changes
IslandRhythms fe02cfd
Merge branch 'main' into IslandRhythms/task-visualizer
IslandRhythms 974a9b8
cleanup warnings and errors in console
IslandRhythms 538b843
fix: lint
IslandRhythms 86d3e59
fix css
IslandRhythms 451045b
Update navbar.html
IslandRhythms 5f57994
task details
IslandRhythms 7f04242
more frontend work
IslandRhythms 386b5a8
cleanup
IslandRhythms 6e104bb
UI polishing
IslandRhythms 4cd32ea
missed a spot
IslandRhythms c066231
remove unused functions
IslandRhythms 9e2f44d
remove unnecessary watcher
IslandRhythms a4fd90f
fix: lint
IslandRhythms 29c9bdf
complete task visualizer
IslandRhythms 684d890
fix: lint
IslandRhythms 8a27ee2
Update eslint.config.js
IslandRhythms 24dd8ca
fix: model navigation not working
IslandRhythms c55eba7
Update models.js
IslandRhythms 8b3943a
Merge branch 'main' into IslandRhythms/task-visualizer
vkarpov15 fd26468
manually fix lint
IslandRhythms 57da3ce
Merge branch 'main' into IslandRhythms/task-visualizer
IslandRhythms 5a994ee
better UX
IslandRhythms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
| 'use strict'; | ||
|
|
||
| const Archetype = require('archetype'); | ||
| const mongoose = require('mongoose'); | ||
|
|
||
| const CancelTaskParams = new Archetype({ | ||
| taskId: { | ||
| $type: mongoose.Types.ObjectId, | ||
| $required: true | ||
| } | ||
| }).compile('CancelTaskParams'); | ||
|
|
||
| module.exports = ({ db }) => async function cancelTask(params) { | ||
| params = new CancelTaskParams(params); | ||
| const { taskId } = params; | ||
| const { Task } = db.models; | ||
|
|
||
| const task = await Task.findOne({ _id: taskId }).orFail(); | ||
|
|
||
| const cancelledTask = await Task.cancelTask({ _id: taskId }); | ||
| return { | ||
| task: cancelledTask | ||
| }; | ||
| }; |
This file contains hidden or 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,33 @@ | ||
| 'use strict'; | ||
|
|
||
| const Archetype = require('archetype'); | ||
|
|
||
| const CreateTaskParams = new Archetype({ | ||
| name: { | ||
| $type: 'string', | ||
| $required: true | ||
| }, | ||
| scheduledAt: { | ||
| $type: Date, | ||
| $required: true | ||
| }, | ||
| repeatAfterMS: { | ||
| $type: 'number' | ||
| }, | ||
| payload: { | ||
| $type: Archetype.Any | ||
| } | ||
| }).compile('CreateTaskParams'); | ||
|
|
||
| module.exports = ({ db }) => async function createTask(params) { | ||
| params = new CreateTaskParams(params); | ||
|
|
||
| const { name, scheduledAt, payload, repeatAfterMS } = params; | ||
| const { Task } = db.models; | ||
|
|
||
| const task = await Task.schedule(name, scheduledAt, payload, repeatAfterMS); | ||
|
|
||
| return { | ||
| task | ||
| }; | ||
| }; |
This file contains hidden or 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,62 @@ | ||
| 'use strict'; | ||
|
|
||
| const Archetype = require('archetype'); | ||
|
|
||
| const GetTasksParams = new Archetype({ | ||
| start: { | ||
| $type: Date | ||
| }, | ||
| end: { | ||
| $type: Date | ||
| }, | ||
| status: { | ||
| $type: 'string' | ||
| }, | ||
| name: { | ||
| $type: 'string' | ||
| } | ||
| }).compile('GetTasksParams'); | ||
|
|
||
| module.exports = ({ db }) => async function getTasks(params) { | ||
| params = new GetTasksParams(params); | ||
| const { start, end, status, name } = params; | ||
| const { Task } = db.models; | ||
|
|
||
| const filter = {}; | ||
|
|
||
| if (start && end) { | ||
| filter.scheduledAt = { $gte: start, $lt: end }; | ||
| } else if (start) { | ||
| filter.scheduledAt = { $gte: start }; | ||
| } | ||
| if (status) { | ||
| filter.status = status; | ||
| } | ||
| if (name) { | ||
| filter.name = { $regex: name, $options: 'i' }; | ||
| } | ||
|
|
||
| const tasks = await Task.find(filter); | ||
|
|
||
| // Define all possible statuses | ||
| const allStatuses = ['pending', 'in_progress', 'succeeded', 'failed', 'cancelled', 'unknown']; | ||
|
|
||
| // Initialize groupedTasks with all statuses | ||
| const groupedTasks = allStatuses.reduce((groups, status) => { | ||
| groups[status] = []; | ||
| return groups; | ||
| }, {}); | ||
|
|
||
| // Group tasks by status | ||
| tasks.forEach(task => { | ||
| const taskStatus = task.status || 'unknown'; | ||
| if (groupedTasks.hasOwnProperty(taskStatus)) { | ||
| groupedTasks[taskStatus].push(task); | ||
| } | ||
| }); | ||
|
|
||
| return { | ||
| tasks, | ||
| groupedTasks | ||
| }; | ||
| }; |
This file contains hidden or 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 @@ | ||
| 'use strict'; | ||
|
|
||
| exports.cancelTask = require('./cancelTask'); | ||
| exports.createTask = require('./createTask'); | ||
| exports.getTasks = require('./getTasks'); | ||
| exports.rescheduleTask = require('./rescheduleTask'); | ||
| exports.runTask = require('./runTask'); |
This file contains hidden or 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,39 @@ | ||
| 'use strict'; | ||
|
|
||
| const Archetype = require('archetype'); | ||
| const mongoose = require('mongoose'); | ||
|
|
||
| const RescheduleTaskParams = new Archetype({ | ||
| taskId: { | ||
| $type: mongoose.Types.ObjectId, | ||
| $required: true | ||
| }, | ||
| scheduledAt: { | ||
| $type: Date, | ||
| $required: true | ||
| } | ||
| }).compile('RescheduleTaskParams'); | ||
|
|
||
| module.exports = ({ db }) => async function rescheduleTask(params) { | ||
| params = new RescheduleTaskParams(params); | ||
| const { taskId, scheduledAt } = params; | ||
| const { Task } = db.models; | ||
|
|
||
| const task = await Task.findOne({ _id: taskId }).orFail(); | ||
|
|
||
| if (scheduledAt < Date.now()) { | ||
| throw new Error('Cannot reschedule a task for the past'); | ||
| } | ||
|
|
||
| if (task.status != 'pending') { | ||
| throw new Error('Cannot reschedule a task that is not pending'); | ||
| } | ||
|
|
||
| task.scheduledAt = scheduledAt; | ||
|
|
||
| await task.save(); | ||
|
|
||
| return { | ||
| task | ||
| }; | ||
| }; |
This file contains hidden or 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,25 @@ | ||
| 'use strict'; | ||
|
|
||
| const Archetype = require('archetype'); | ||
| const mongoose = require('mongoose'); | ||
|
|
||
| const RunTaskParams = new Archetype({ | ||
| taskId: { | ||
| $type: mongoose.Types.ObjectId, | ||
| $required: true | ||
| } | ||
| }).compile('RunTaskParams'); | ||
|
|
||
| module.exports = ({ db }) => async function runTask(params) { | ||
| params = new RunTaskParams(params); | ||
| const { taskId } = params; | ||
| const { Task } = db.models; | ||
|
|
||
| const task = await Task.findOne({ _id: taskId }).orFail(); | ||
|
|
||
| const executedTask = await Task.execute(task); | ||
|
|
||
| return { | ||
| task: executedTask | ||
| }; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The global navigation guard's logic appears inverted: routes marked as 'authorized' are immediately permitted without an access check, while those with 'authorized' set to false require role validation. Please verify that the flag's semantics and its usage in routes match the intended access control behavior.