Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
pleroma
Commits
092ceded
Commit
092ceded
authored
6 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
activity: add with_preloaded_object() convenience
parent
62bccddd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1912
Feature/static fe
,
!967
preloaded object normalization
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/activity.ex
+18
-0
18 additions, 0 deletions
lib/pleroma/activity.ex
with
18 additions
and
0 deletions
lib/pleroma/activity.ex
+
18
−
0
View file @
092ceded
...
...
@@ -44,11 +44,29 @@ defmodule Pleroma.Activity do
# fragment("(?->>'id') = COALESCE((? -> 'object'::text) ->> 'id'::text)", o.data, activity.data))
# |> preload([activity, object], [object: object])
# ```
#
# As a convenience, Activity.with_preloaded_object() sets up an inner join and preload for the
# typical case.
has_one
(
:object
,
Object
,
on_delete:
:nothing
,
foreign_key:
:id
)
timestamps
()
end
def
with_preloaded_object
(
query
)
do
query
|>
join
(
:inner
,
[
activity
],
o
in
Object
,
fragment
(
"(?->>'id') = COALESCE((? -> 'object'::text) ->> 'id'::text)"
,
o
.
data
,
activity
.
data
)
)
|>
preload
([
activity
,
object
],
object:
object
)
end
def
get_by_ap_id
(
ap_id
)
do
Repo
.
one
(
from
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment