This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 278
[WIP] upload scheduled query metadata #504
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
53e2869
remove setting of default refreshInterval from frontend
briandennis 47d161d
add backend support for uploading metadata on create/update of queries
briandennis 4f187b9
avoid throwing on null cronInterval in mapCronToRefresh
briandennis 4bbfc6e
use mapCronToRefresh to set default refresh interval
briandennis e9f7a91
update jest tests to account for refreshInterval not being set by fro…
briandennis 97dd563
add metadata specific error message
briandennis 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 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
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 |
---|---|---|
|
@@ -664,13 +664,22 @@ export default class Servers { | |
* the endpoint `/queries/:fid` | ||
*/ | ||
server.post('/queries', function postQueriesHandler(req, res, next) { | ||
const {filename, fid, uids, query, connectionId, requestor} = req.params; | ||
const { | ||
filename, | ||
fid, | ||
uids, | ||
query, | ||
connectionId, | ||
requestor, | ||
cronInterval = null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. out of curiosity, why setting the default to 'null'? |
||
refreshInterval = null | ||
} = req.params; | ||
|
||
// If a filename has been provided, | ||
// make the query and create a new grid | ||
if (filename) { | ||
return that.queryScheduler.queryAndCreateGrid( | ||
filename, query, connectionId, requestor | ||
filename, query, connectionId, requestor, cronInterval, refreshInterval | ||
) | ||
.then((newGridResponse) => { | ||
const queryObject = { | ||
|
@@ -691,7 +700,7 @@ export default class Servers { | |
if (fid) { | ||
return checkWritePermissions(fid, requestor).then(function () { | ||
return that.queryScheduler.queryAndUpdateGrid( | ||
fid, uids, query, connectionId, requestor | ||
fid, uids, query, connectionId, requestor, cronInterval, refreshInterval | ||
); | ||
}) | ||
.then(() => { | ||
|
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 |
---|---|---|
|
@@ -22,6 +22,26 @@ export function mapRefreshToCron (refreshInterval) { | |
return `${now.getMinutes()} ${now.getHours()} * * ${now.getDay()}`; | ||
} | ||
|
||
export function mapCronToRefresh (cronInterval) { | ||
const DEFAULT_INTERVAL = 60 * 60 * 24 * 7; // default to weekly | ||
|
||
if (!cronInterval) { | ||
return DEFAULT_INTERVAL; | ||
} | ||
|
||
if (cronInterval === '* * * * *') { | ||
return 60; | ||
} else if (cronInterval === '*/5 * * * *') { | ||
return 60 * 5; | ||
} else if (cronInterval.match(/\S+? \* \* \* \*/)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this throws when |
||
return 60 * 60; | ||
} else if (cronInterval.match(/\S+? \S+? \* \* \*/)) { | ||
return 60 * 60 * 24; | ||
} | ||
|
||
return DEFAULT_INTERVAL; | ||
} | ||
|
||
function computeMinutes (now) { | ||
let currMinute = now.getMinutes() % 5; // start at 5 min offset | ||
const minutes = []; | ||
|
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.
👍