Skip to content

Instantly share code, notes, and snippets.

@karlosmid
Created January 24, 2021 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlosmid/8448e121cf23499c949900a1e15fd9ce to your computer and use it in GitHub Desktop.
Save karlosmid/8448e121cf23499c949900a1e15fd9ce to your computer and use it in GitHub Desktop.
Query that returns sensitive information
@spec query_active_charter_sessions(integer(), NaiveDateTime.t()) :: Ecto.Query.t()
def query_active_charter_sessions(charter_id, active_threshold) do
from(s in Session,
join: c in Charter,
on: c.id == s.charter_id,
where: c.id == ^charter_id,
where: ^active_threshold <= s.inserted_at,
preload: :author
)
end
%Testivator.SRM.Session{
__meta__: #Ecto.Schema.Metadata<:loaded, "sessions">,
author: %Testivator.URM.User{
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
activation_token: nil,
activation_token_activated_at: ~U[2021-01-24 10:22:42Z],
activation_token_expires_at: ~U[2021-01-24 10:27:42Z],
auth_tokens: #Ecto.Association.NotLoaded<association :auth_tokens is not loaded>,
charters: #Ecto.Association.NotLoaded<association :charters is not loaded>,
current_sign_in_at: nil,
current_sign_in_ip: nil,
email: "mobber02@test.com",
id: 194452,
inserted_at: ~N[2021-01-24 10:22:42],
last_sign_in_at: nil,
last_sign_in_ip: nil,
name: "Sid Dickens",
new_password: nil,
password: nil,
password_hash: "$2b$04$3VFG9oG8MhKPS5//B3Usd.nKq7rveavR0wgA0kML1nRrTyoe3CkpS",
password_reset_token: nil,
password_reset_token_expires_at: nil,
profile: #Ecto.Association.NotLoaded<association :profile is not loaded>,
project: #Ecto.Association.NotLoaded<association :project is not loaded>,
reports: #Ecto.Association.NotLoaded<association :reports is not loaded>,
role: #Ecto.Association.NotLoaded<association :role is not loaded>,
role_id: 172174,
session: #Ecto.Association.NotLoaded<association :session is not loaded>,
updated_at: ~N[2021-01-24 10:22:42]
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment