0.2.6
- Fix sorting posts by rule
This commit is contained in:
parent
c94158a3a6
commit
30bd140483
3 changed files with 17 additions and 6 deletions
|
|
@ -9,11 +9,11 @@ deploy:
|
|||
before_script:
|
||||
- pip install ansible --quiet
|
||||
- git clone https://git.fudiggity.nl/sonny/ansible-playbooks.git deployment
|
||||
- mkdir /root/.ssh
|
||||
- mkdir -p /root/.ssh
|
||||
- echo "$DEPLOY_HOST_KEY" > /root/.ssh/known_hosts
|
||||
- echo "$DEPLOY_KEY" > deployment/deploy_key && chmod 0600 deployment/deploy_key
|
||||
- mkdir /root/.vaults
|
||||
- echo "$VAULT_PASSWORD" > deployment/vault && chmod 0700 deployment/vault
|
||||
- mkdir -p /root/.vaults
|
||||
- echo "$VAULT_PASSWORD" > /root/.vaults/newsreader && chmod 0600 /root/.vaults/newsreader
|
||||
script:
|
||||
- >
|
||||
ansible-playbook deployment/playbook.yml
|
||||
|
|
@ -21,4 +21,4 @@ deploy:
|
|||
--limit newsreader
|
||||
--user ansible
|
||||
--private-key deployment/deploy_key
|
||||
--vault-password-file deployment/vault
|
||||
--vault-password-file /root/.vaults/newsreader
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ export const filterPostsByRule = (rule = {}, posts = []) => {
|
|||
|
||||
const filteredData = filteredPosts.map(post => ({ ...post, rule: { ...rule } }));
|
||||
|
||||
return filteredData.length > 0 ? [...filteredData] : [];
|
||||
return filteredData.sort((firstPost, secondPost) => {
|
||||
return new Date(secondPost.publicationDate) - new Date(firstPost.publicationDate);
|
||||
});
|
||||
};
|
||||
|
||||
export const filterPostsByCategory = (category = {}, rules = [], posts = []) => {
|
||||
|
|
|
|||
|
|
@ -165,7 +165,12 @@ class NestedRuleListViewTestCase(TestCase):
|
|||
|
||||
def test_pagination(self):
|
||||
rule = FeedFactory.create(user=self.user)
|
||||
FeedPostFactory.create_batch(size=80, rule=rule)
|
||||
|
||||
posts = sorted(
|
||||
FeedPostFactory.create_batch(size=80, rule=rule),
|
||||
key=lambda post: post.publication_date,
|
||||
reverse=True,
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
reverse("api:news:collection:rules-nested-posts", kwargs={"pk": rule.pk}),
|
||||
|
|
@ -177,6 +182,10 @@ class NestedRuleListViewTestCase(TestCase):
|
|||
self.assertEquals(data["count"], 80)
|
||||
self.assertEquals(len(data["results"]), 30)
|
||||
|
||||
self.assertEquals(
|
||||
[post["id"] for post in data["results"]], [post.id for post in posts[:30]]
|
||||
)
|
||||
|
||||
def test_empty(self):
|
||||
rule = FeedFactory.create(user=self.user)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue