-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2636 reduce usage tracker memory usage (#2667)
* Stream runs when generating usage tracking reports * Cleanup redundant tests * Clean up obsolete endpoint * Update CHANGELOG * Replace env setting with Mox --------- Co-authored-by: Stuart Corbishley <[email protected]>
- Loading branch information
1 parent
7fe5798
commit 119bb2e
Showing
14 changed files
with
412 additions
and
317 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
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,31 @@ | ||
defmodule Lightning.UsageTracking.WorkflowMetricsQuery do | ||
@moduledoc """ | ||
Query module to support workflow metrics while allowing for fewer test | ||
permutations. | ||
""" | ||
import Ecto.Query | ||
|
||
alias Lightning.Run | ||
|
||
def workflow_runs(%{id: workflow_id}) do | ||
from r in Run, | ||
join: w in assoc(r, :workflow), | ||
on: w.id == ^workflow_id | ||
end | ||
|
||
def runs_finished_on(query, date) do | ||
start_of_day = DateTime.new!(date, ~T[00:00:00]) | ||
|
||
start_of_next_day = | ||
date | ||
|> Date.add(1) | ||
|> DateTime.new!(~T[00:00:00]) | ||
|
||
from r in query, | ||
where: not is_nil(r.finished_at), | ||
where: r.finished_at >= ^start_of_day, | ||
where: r.finished_at < ^start_of_next_day | ||
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
Oops, something went wrong.