Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit1f13097

Browse files
authored
chore(orm): play around cursor-based paginator (#422)
1 parent94a2329 commit1f13097

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

‎lib/groupher_server/cms/delegates/article_curd.ex‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
101101
|>QueryBuilder.domain_query(filter)
102102
|>QueryBuilder.filter_pack(Map.merge(filter,%{mark_delete:false}))
103103
|>ORM.paginator(~m(page size)a)
104+
# |> ORM.cursor_paginator()
104105
|>add_pin_articles_ifneed(info.model,filter)
105106
|>done()
106107
end

‎lib/helper/orm.ex‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ defmodule Helper.ORM do
2727
result|>Map.put(:total_count,total_count)|>Map.drop([:total_entries])
2828
end
2929

30+
@doc"""
31+
cursor-based paginator, works well
32+
see: https://hexdocs.pm/quarto/Quarto.html
33+
"""
34+
defcursor_paginator(queryable)do
35+
queryable|>Quarto.paginate([limit:10],Repo)
36+
end
37+
3038
# NOTE: should have limit length for list, otherwise it will cause mem issues
3139
@doc"simu paginator in normal list, used for embeds_many etc"
3240
defembeds_paginator(list,%{page:page,size:size}=_filter)whenis_list(list)do

‎mix.exs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ defmodule GroupherServer.Mixfile do
7575
# for fake data in test env
7676
{:faker,"~> 0.9"},
7777
{:scrivener_ecto,"~> 2.7.0"},
78-
# cursor based pagination
79-
{:paginator,"~> 1.0.4"},
78+
#enhancedcursor based pagination
79+
{:quarto,"~> 1.1.5"},
8080
{:guardian,"~> 2.0"},
8181
{:timex,"~> 3.7.5"},
8282
{:dataloader,"~> 1.0.7"},

‎mix.lock‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
"elixir_uuid":{:hex,:elixir_uuid,"1.2.1","dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097",[],[],"hexpm","f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
3333
"erlex":{:hex,:erlex,"0.2.6","c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e",[:mix],[],"hexpm","2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
3434
"eternal":{:hex,:eternal,"1.2.2","d1641c86368de99375b98d183042dd6c2b234262b8d08dfd72b9eeaafc2a1abd",[:mix],[],"hexpm","2c9fe32b9c3726703ba5e1d43a1d255a4f3f2d8f8f9bc19f094c7cb1a7a9e782"},
35+
"ex_doc":{:hex,:ex_doc,"0.24.2","e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9",[:mix],[{:earmark_parser,"~> 1.4.0",[hex::earmark_parser,repo:"hexpm",optional:false]},{:makeup_elixir,"~> 0.14",[hex::makeup_elixir,repo:"hexpm",optional:false]},{:makeup_erlang,"~> 0.1",[hex::makeup_erlang,repo:"hexpm",optional:false]}],"hexpm","e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"},
3536
"ex_unit_notifier":{:hex,:ex_unit_notifier,"1.1.0","a4d1a027d975a2ba84cec60200e3cb095fe1de6c6b63091ca0880e83830b09bb",[:mix],[],"hexpm","12d78f3a62c521ee4c9f18bd01ea3b960a3200d5ca21a383b0707f4228486c4e"},
37+
"ex_zstd":{:hex,:ex_zstd,"0.1.0","4b1b5ebd7c0417e69308db8cdd478b9adb3e2d1a03b6e7366cf0a9aadeae11af",[:make,:mix],[{:ex_doc,">= 0.0.0",[hex::ex_doc,repo:"hexpm",optional:false]}],"hexpm","2c9542a5c088e0eab14aa9b10d18bc084a6060ecf09025bbfc5b08684568bc67"},
3638
"excoveralls":{:hex,:excoveralls,"0.14.1","14140e4ef343f2af2de33d35268c77bc7983d7824cb945e6c2af54235bc2e61f",[:mix],[{:hackney,"~> 1.16",[hex::hackney,repo:"hexpm",optional:false]},{:jason,"~> 1.0",[hex::jason,repo:"hexpm",optional:false]}],"hexpm","4a588f9f8cf9dc140cc1f3d0ea4d849b2f76d5d8bee66b73c304bb3d3689c8b0"},
3739
"faker":{:hex,:faker,"0.16.0","1e2cf3e8d60d44a30741fb98118fcac18b2020379c7e00d18f1a005841b2f647",[:mix],[],"hexpm","fbcb9bf1299dff3c9dd7e50f41802bbc472ffbb84e7656394c8aa913ec315141"},
3840
"file_system":{:hex,:file_system,"0.2.8","f632bd287927a1eed2b718f22af727c5aeaccc9a98d8c2bd7bff709e851dc986",[:mix],[],"hexpm","97a3b6f8d63ef53bd0113070102db2ce05352ecf0d25390eb8d747c2bde98bca"},
@@ -53,6 +55,9 @@
5355
"jose":{:hex,:jose,"1.11.1","59da64010c69aad6cde2f5b9248b896b84472e99bd18f246085b7b9fe435dcdb",[:mix,:rebar3],[],"hexpm","078f6c9fb3cd2f4cfafc972c814261a7d1e8d2b3685c0a76eb87e158efff1ac5"},
5456
"jumper":{:hex,:jumper,"1.0.1","3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff",[:mix],[],"hexpm","318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
5557
"libring":{:hex,:libring,"1.4.0","41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6",[:mix],[],"hexpm","1feaf05ee886815ad047cad7ede17d6910710986148ae09cf73eee2989717b81"},
58+
"makeup":{:hex,:makeup,"1.0.5","d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c",[:mix],[{:nimble_parsec,"~> 0.5 or ~> 1.0",[hex::nimble_parsec,repo:"hexpm",optional:false]}],"hexpm","cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
59+
"makeup_elixir":{:hex,:makeup_elixir,"0.15.1","b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd",[:mix],[{:makeup,"~> 1.0",[hex::makeup,repo:"hexpm",optional:false]},{:nimble_parsec,"~> 1.1",[hex::nimble_parsec,repo:"hexpm",optional:false]}],"hexpm","db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
60+
"makeup_erlang":{:hex,:makeup_erlang,"0.1.1","3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f",[:mix],[{:makeup,"~> 1.0",[hex::makeup,repo:"hexpm",optional:false]}],"hexpm","174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
5661
"metrics":{:hex,:metrics,"1.0.1","25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486",[:rebar3],[],"hexpm","69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
5762
"mime":{:hex,:mime,"1.6.0","dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2",[:mix],[],"hexpm","31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"},
5863
"mimerl":{:hex,:mimerl,"1.2.0","67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3",[:rebar3],[],"hexpm","f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
@@ -77,6 +82,7 @@
7782
"postgrex":{:hex,:postgrex,"0.15.9","46f8fe6f25711aeb861c4d0ae09780facfdf3adbd2fb5594ead61504dd489bda",[:mix],[{:connection,"~> 1.0",[hex::connection,repo:"hexpm",optional:false]},{:db_connection,"~> 2.1",[hex::db_connection,repo:"hexpm",optional:false]},{:decimal,"~> 1.5 or ~> 2.0",[hex::decimal,repo:"hexpm",optional:false]},{:jason,"~> 1.0",[hex::jason,repo:"hexpm",optional:true]}],"hexpm","610719103e4cb2223d4ab78f9f0f3e720320eeca6011415ab4137ddef730adee"},
7883
"pre_commit":{:hex,:pre_commit,"0.3.4","e2850f80be8090d50ad8019ef2426039307ff5dfbe70c736ad0d4d401facf304",[:mix],[],"hexpm","16f684ba4f1fed1cba6b19e082b0f8d696e6f1c679285fedf442296617ba5f4e"},
7984
"quantum":{:hex,:quantum,"2.3.4","72a0e8855e2adc101459eac8454787cb74ab4169de6ca50f670e72142d4960e9",[:mix],[{:calendar,"~> 0.17",[hex::calendar,repo:"hexpm",optional:true]},{:crontab,"~> 1.1",[hex::crontab,repo:"hexpm",optional:false]},{:gen_stage,"~> 0.12",[hex::gen_stage,repo:"hexpm",optional:false]},{:swarm,"~> 3.3",[hex::swarm,repo:"hexpm",optional:false]},{:timex,"~> 3.1",[hex::timex,repo:"hexpm",optional:true]}],"hexpm","6de553ba9ac0668d3728b699d5065543f3e40c854154017461ee8c09038752da"},
85+
"quarto":{:hex,:quarto,"1.1.5","2f4bbf923f64951b1600be2ee1f52c98cbf76d3e266aa177514797c5be2cfd32",[:mix],[{:ecto_sql,"~> 3.4",[hex::ecto_sql,repo:"hexpm",optional:false]},{:plug_crypto,"~> 1.1.2 or ~> 1.2",[hex::plug_crypto,repo:"hexpm",optional:false]}],"hexpm","d804342dedcf1bae671a4c0cb872b0c5406481ccb3147289f971b6cef64d2ec0"},
8086
"ranch":{:hex,:ranch,"1.7.1","6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881",[:rebar3],[],"hexpm","451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
8187
"recase":{:hex,:recase,"0.7.0","3f2f719f0886c7a3b7fe469058ec539cb7bbe0023604ae3bce920e186305e5ae",[:mix],[],"hexpm","36f5756a9f552f4a94b54a695870e32f4e72d5fad9c25e61bc4a3151c08a4e0c"},
8288
"rihanna":{:hex,:rihanna,"1.3.5","5f5e6c5b1e514978a29a6791f338f4bb963401959fc212bd18d4a2c92d79a7a4",[:mix],[{:ecto,">= 2.0.0",[hex::ecto,repo:"hexpm",optional:true]},{:ecto_sql,">= 3.0.0",[hex::ecto_sql,repo:"hexpm",optional:true]},{:postgrex,">= 0.13.3",[hex::postgrex,repo:"hexpm",optional:false]}],"hexpm","fa1918c2ab63c8ada9a23ad6fe03cd181378739f0ff10741b45d0bcb50003c74"},

‎test/groupher_server/cms/comments/meetup_comment_test.exs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ defmodule GroupherServer.Test.CMS.Comments.MeetupComment do
373373
end
374374

375375
describe"paged article comments"do
376-
@tag:wip
377376
test"can load paged comments participants of a article",~m(user meetup)ado
378377
total_count=30
379378
page_size=10

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp