Skip to content

Commit

Permalink
0.7.4 release Version.first() && Version.last()
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Apr 9, 2017
1 parent 9852dc3 commit eb51f4f
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 35 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ PaperTrail is assailed with hundreds of test assertions for each release. Data i
# item_id: 1, item_type: "Post", originator_id: nil, originator: nil, meta: nil}}}

Repo.aggregate(Post, :count, :id) # => 0
Repo.aggregate(PaperTrail.Version, :count, :id) # => 3
PaperTrail.Version.count() # => 3
# same as Repo.aggregate(PaperTrail.Version, :count, :id)

last(PaperTrail.Version, :id) |> Repo.one
PaperTrail.Version.last() # returns the last version in the db by inserted_at
# %PaperTrail.Version{__meta__: #Ecto.Schema.Metadata<:loaded, "versions">,
# event: "delete", id: 3, inserted_at: #Ecto.DateTime<2016-09-15 22:22:12>,
# item_changes: %{"title" => "Elixir matures fast", content: "Future is already here, Elixir is the next step!", "id" => 1,
Expand Down Expand Up @@ -351,9 +352,10 @@ Bang functions assume the operation will always be successful, otherwise functio
# item_id: 1, item_type: "Post", originator_id: nil, originator: nil, meta: nil}

Repo.aggregate(Post, :count, :id) # => 0
Repo.aggregate(PaperTrail.Version, :count, :id) # => 3
PaperTrail.Version.count() # => 3
# same as Repo.aggregate(PaperTrail.Version, :count, :id)

last(PaperTrail.Version, :id) |> Repo.one
PaperTrail.Version.last() # returns the last version in the db by inserted_at
# %PaperTrail.Version{__meta__: #Ecto.Schema.Metadata<:loaded, "versions">,
# event: "delete", id: 3, inserted_at: #Ecto.DateTime<2016-09-15 22:22:12>,
# item_changes: %{"title" => "Elixir matures fast", content: "Future is already here, Elixir is the next step!", "id" => 1,
Expand Down
2 changes: 1 addition & 1 deletion doc/.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fonts/icomoon.eot
fonts/icomoon.svg
fonts/icomoon.ttf
fonts/icomoon.woff
dist/sidebar_items-7c98857fb6.js
dist/sidebar_items-295d4039c8.js
api-reference.html
index.html
404.html
Expand Down
6 changes: 3 additions & 3 deletions doc/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>404 – paper_trail v0.7.3</title>
<title>404 – paper_trail v0.7.4</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/404.html" />

<script src="dist/sidebar_items-7c98857fb6.js"></script>
<script src="dist/sidebar_items-295d4039c8.js"></script>
</head>
<body data-type="extras">
<script>if(localStorage.getItem('night-mode')) document.body.className += ' night-mode';</script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.7.3
v0.7.4
</h2>
</div>

Expand Down
8 changes: 4 additions & 4 deletions doc/Mix.Tasks.Papertrail.Install.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>Mix.Tasks.Papertrail.Install – paper_trail v0.7.3</title>
<title>Mix.Tasks.Papertrail.Install – paper_trail v0.7.4</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/Mix.Tasks.Papertrail.Install.html" />

<script src="dist/sidebar_items-7c98857fb6.js"></script>
<script src="dist/sidebar_items-295d4039c8.js"></script>
</head>
<body data-type="modules">
<script>if(localStorage.getItem('night-mode')) document.body.className += ' night-mode';</script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.7.3
v0.7.4
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.7.3</small>
<small class="visible-xs">paper_trail v0.7.4</small>
Mix.Tasks.Papertrail.Install


Expand Down
8 changes: 4 additions & 4 deletions doc/PaperTrail.RepoClient.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail.RepoClient – paper_trail v0.7.3</title>
<title>PaperTrail.RepoClient – paper_trail v0.7.4</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.RepoClient.html" />

<script src="dist/sidebar_items-7c98857fb6.js"></script>
<script src="dist/sidebar_items-295d4039c8.js"></script>
</head>
<body data-type="modules">
<script>if(localStorage.getItem('night-mode')) document.body.className += ' night-mode';</script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.7.3
v0.7.4
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.7.3</small>
<small class="visible-xs">paper_trail v0.7.4</small>
PaperTrail.RepoClient


Expand Down
62 changes: 58 additions & 4 deletions doc/PaperTrail.Version.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail.Version – paper_trail v0.7.3</title>
<title>PaperTrail.Version – paper_trail v0.7.4</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.Version.html" />

<script src="dist/sidebar_items-7c98857fb6.js"></script>
<script src="dist/sidebar_items-295d4039c8.js"></script>
</head>
<body data-type="modules">
<script>if(localStorage.getItem('night-mode')) document.body.className += ' night-mode';</script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.7.3
v0.7.4
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.7.3</small>
<small class="visible-xs">paper_trail v0.7.4</small>
PaperTrail.Version


Expand Down Expand Up @@ -94,6 +94,27 @@ <h2>
<a href="#count/0">count()</a>
</div>

<div class="summary-synopsis"><p>Returns the count of all version records in the database</p>
</div>

</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#first/0">first()</a>
</div>

<div class="summary-synopsis"><p>Returns the first version record in the database by :inserted_at</p>
</div>

</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#last/0">last()</a>
</div>

<div class="summary-synopsis"><p>Returns the last version record in the database by :inserted_at</p>
</div>

</div>

</div>
Expand Down Expand Up @@ -145,7 +166,40 @@ <h1 class="section-heading">

</div>
<section class="docstring">
<p>Returns the count of all version records in the database</p>

</section>
</div>
<div class="detail" id="first/0">

<div class="detail-header">
<a href="#first/0" class="detail-link" title="Link to this function">
<i class="icon-link"></i>
</a>
<span class="signature">first()</span>



</div>
<section class="docstring">
<p>Returns the first version record in the database by :inserted_at</p>

</section>
</div>
<div class="detail" id="last/0">

<div class="detail-header">
<a href="#last/0" class="detail-link" title="Link to this function">
<i class="icon-link"></i>
</a>
<span class="signature">last()</span>



</div>
<section class="docstring">
<p>Returns the last version record in the database by :inserted_at</p>

</section>
</div>

Expand Down
8 changes: 4 additions & 4 deletions doc/PaperTrail.VersionQueries.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail.VersionQueries – paper_trail v0.7.3</title>
<title>PaperTrail.VersionQueries – paper_trail v0.7.4</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.VersionQueries.html" />

<script src="dist/sidebar_items-7c98857fb6.js"></script>
<script src="dist/sidebar_items-295d4039c8.js"></script>
</head>
<body data-type="modules">
<script>if(localStorage.getItem('night-mode')) document.body.className += ' night-mode';</script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.7.3
v0.7.4
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.7.3</small>
<small class="visible-xs">paper_trail v0.7.4</small>
PaperTrail.VersionQueries


Expand Down
8 changes: 4 additions & 4 deletions doc/PaperTrail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail – paper_trail v0.7.3</title>
<title>PaperTrail – paper_trail v0.7.4</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.html" />

<script src="dist/sidebar_items-7c98857fb6.js"></script>
<script src="dist/sidebar_items-295d4039c8.js"></script>
</head>
<body data-type="modules">
<script>if(localStorage.getItem('night-mode')) document.body.className += ' night-mode';</script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.7.3
v0.7.4
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.7.3</small>
<small class="visible-xs">paper_trail v0.7.4</small>
PaperTrail


Expand Down
8 changes: 4 additions & 4 deletions doc/api-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>API Reference – paper_trail v0.7.3</title>
<title>API Reference – paper_trail v0.7.4</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/api-reference.html" />

<script src="dist/sidebar_items-7c98857fb6.js"></script>
<script src="dist/sidebar_items-295d4039c8.js"></script>
</head>
<body data-type="extras">
<script>if(localStorage.getItem('night-mode')) document.body.className += ' night-mode';</script>
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.7.3
v0.7.4
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.7.3</small>
<small class="visible-xs">paper_trail v0.7.4</small>
API Reference
</h1>

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>paper_trail v0.7.3 – Documentation</title>
<title>paper_trail v0.7.4 – Documentation</title>
<meta http-equiv="refresh" content="0; url=api-reference.html">
<meta name="robots" content="noindex">
<meta name="generator" content="ExDoc v0.14.5">
Expand Down
19 changes: 19 additions & 0 deletions lib/version.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,26 @@ defmodule PaperTrail.Version do
|> validate_required([:event, :item_type, :item_id, :item_changes])
end

@doc """
Returns the count of all version records in the database
"""
def count do
from(version in __MODULE__, select: count(version.id)) |> PaperTrail.RepoClient.repo.one
end

@doc """
Returns the first version record in the database by :inserted_at
"""
def first do
from(record in __MODULE__, limit: 1, order_by: [asc: :inserted_at])
|> PaperTrail.RepoClient.repo.one
end

@doc """
Returns the last version record in the database by :inserted_at
"""
def last do
from(record in __MODULE__, limit: 1, order_by: [desc: :inserted_at])
|> PaperTrail.RepoClient.repo.one
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule PaperTrail.Mixfile do
def project do
[
app: :paper_trail,
version: "0.7.3",
version: "0.7.4",
elixir: "~> 1.4",
description: description(),
build_embedded: Mix.env == :prod,
Expand Down
Loading

0 comments on commit eb51f4f

Please sign in to comment.