Browse Source

Clarify various SQL queries

J. King 1 week ago
parent
commit
e2cba68c1b
2 changed files with 139 additions and 104 deletions
  1. 86
    94
      lib/Database.php
  2. 53
    10
      tests/cases/Database/SeriesFolder.php

+ 86
- 94
lib/Database.php View File

@@ -428,14 +428,18 @@ class Database {
428 428
         $parent = $this->folderValidateId($user, $parent)['id'];
429 429
         $q = new Query(
430 430
             "SELECT
431
-                id,name,parent,
432
-                (select count(*) from arsse_folders as parents where coalesce(parents.parent,0) = coalesce(arsse_folders.id,0)) as children,
433
-                (select count(*) from arsse_subscriptions where coalesce(folder,0) = coalesce(arsse_folders.id,0)) as feeds
434
-            FROM arsse_folders"
431
+                id,
432
+                name,
433
+                arsse_folders.parent as parent,
434
+                coalesce(children,0) as children, 
435
+                coalesce(feeds,0) as feeds
436
+            FROM arsse_folders
437
+            left join (SELECT parent,count(id) as children from arsse_folders group by parent) as child_stats on child_stats.parent = arsse_folders.id
438
+            left join (SELECT folder,count(id) as feeds from arsse_subscriptions group by folder) as sub_stats on sub_stats.folder = arsse_folders.id"
435 439
         );
436 440
         if (!$recursive) {
437 441
             $q->setWhere("owner = ?", "str", $user);
438
-            $q->setWhere("coalesce(parent,0) = ?", "strict int", $parent);
442
+            $q->setWhere("coalesce(arsse_folders.parent,0) = ?", "strict int", $parent);
439 443
         } else {
440 444
             $q->setCTE("folders", "SELECT id from arsse_folders where owner = ? and coalesce(parent,0) = ? union select arsse_folders.id from arsse_folders join folders on arsse_folders.parent=folders.id", ["str", "strict int"], [$user, $parent]);
441 445
             $q->setWhere("id in (SELECT id from folders)");
@@ -687,22 +691,23 @@ class Database {
687 691
         $q = new Query(
688 692
             "SELECT
689 693
                 arsse_subscriptions.id as id,
690
-                feed,url,favicon,source,folder,pinned,err_count,err_msg,order_type,added,
694
+                arsse_subscriptions.feed,
695
+                url,favicon,source,folder,pinned,err_count,err_msg,order_type,added,
691 696
                 arsse_feeds.updated as updated,
692 697
                 topmost.top as top_folder,
693 698
                 coalesce(arsse_subscriptions.title, arsse_feeds.title) as title,
694
-                (SELECT count(*) from arsse_articles where feed = arsse_subscriptions.feed) - (SELECT count(*) from arsse_marks where subscription = arsse_subscriptions.id and \"read\" = 1) as unread
695
-             from arsse_subscriptions
696
-                join userdata on userid = owner
697
-                join arsse_feeds on feed = arsse_feeds.id
698
-                left join topmost on folder=f_id"
699
+                (articles - marked) as unread
700
+            FROM arsse_subscriptions
701
+                left join topmost on topmost.f_id = arsse_subscriptions.folder
702
+                join arsse_feeds on arsse_feeds.id = arsse_subscriptions.feed
703
+                left join (select feed, count(*) as articles from arsse_articles group by feed) as article_stats on article_stats.feed = arsse_subscriptions.feed
704
+                left join (select subscription, sum(\"read\") as marked from arsse_marks group by subscription) as mark_stats on mark_stats.subscription = arsse_subscriptions.id"
699 705
         );
706
+        $q->setWhere("arsse_subscriptions.owner = ?", ["str"], [$user]);
700 707
         $nocase = $this->db->sqlToken("nocase");
701 708
         $q->setOrder("pinned desc, coalesce(arsse_subscriptions.title, arsse_feeds.title) collate $nocase");
702
-        // define common table expressions
703
-        $q->setCTE("userdata(userid)", "SELECT ?", "str", $user);  // the subject user; this way we only have to pass it to prepare() once
704 709
         // topmost folders belonging to the user
705
-        $q->setCTE("topmost(f_id,top)", "SELECT id,id from arsse_folders join userdata on owner = userid where parent is null union select id,top from arsse_folders join topmost on parent=f_id");
710
+        $q->setCTE("topmost(f_id,top)", "SELECT id,id from arsse_folders where owner = ? and parent is null union select id,top from arsse_folders join topmost on parent=f_id", ["str"], [$user]);
706 711
         if ($id) {
707 712
             // this condition facilitates the implementation of subscriptionPropertiesGet, which would otherwise have to duplicate the complex query; it takes precedence over a specified folder
708 713
             // if an ID is specified, add a suitable WHERE condition and bindings
@@ -801,7 +806,7 @@ class Database {
801 806
      * - "order_type": Whether articles should be sorted in reverse cronological order (2), chronological order (1), or the default (0)
802 807
      * 
803 808
      * @param string $user The user whose subscription is to be modified
804
-     * @param integer|null $id the numeric identifier of the subscription to modfify
809
+     * @param integer $id the numeric identifier of the subscription to modfify
805 810
      * @param array $data An associative array of properties to modify; any keys not specified will be left unchanged
806 811
      */
807 812
     public function subscriptionPropertiesSet(string $user, $id, array $data): bool {
@@ -873,7 +878,7 @@ class Database {
873 878
      * Returns an associative array containing the id of the subscription and the id of the underlying newsfeed
874 879
      * 
875 880
      * @param string $user The user who owns the subscription to be validated
876
-     * @param integer|null $id The identifier of the subscription to validate
881
+     * @param integer $id The identifier of the subscription to validate
877 882
      * @param boolean $subject Whether the subscription is the subject (true) rather than the object (false) of the operation being performed; this only affects the semantics of the error message if validation fails
878 883
      */
879 884
     protected function subscriptionValidateId(string $user, $id, bool $subject = false): array {
@@ -1056,9 +1061,9 @@ class Database {
1056 1061
     public function feedCleanup(): bool {
1057 1062
         $tr = $this->begin();
1058 1063
         // first unmark any feeds which are no longer orphaned
1059
-        $this->db->query("UPDATE arsse_feeds set orphaned = null where exists(SELECT id from arsse_subscriptions where feed = arsse_feeds.id)");
1064
+        $this->db->query("WITH active_feeds as (select id from arsse_feeds left join (select feed, count(id) as count from arsse_subscriptions group by feed) as sub_stats on sub_stats.feed = arsse_feeds.id where orphaned is not null and count is not null) UPDATE arsse_feeds set orphaned = null where id in (select id from active_feeds)");
1060 1065
         // next mark any newly orphaned feeds with the current date and time
1061
-        $this->db->query("UPDATE arsse_feeds set orphaned = CURRENT_TIMESTAMP where orphaned is null and not exists(SELECT id from arsse_subscriptions where feed = arsse_feeds.id)");
1066
+        $this->db->query("WITH orphaned_feeds as (select id from arsse_feeds left join (select feed, count(id) as count from arsse_subscriptions group by feed) as sub_stats on sub_stats.feed = arsse_feeds.id where orphaned is null and count is null) UPDATE arsse_feeds set orphaned = CURRENT_TIMESTAMP where id in (select id from orphaned_feeds)");
1062 1067
         // finally delete feeds that have been orphaned longer than the retention period, if a a purge threshold has been specified
1063 1068
         if (Arsse::$conf->purgeFeeds) {
1064 1069
             $limit = Date::sub(Arsse::$conf->purgeFeeds);
@@ -1500,7 +1505,7 @@ class Database {
1500 1505
             throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
1501 1506
         }
1502 1507
         $id = $this->articleValidateId($user, $id)['article'];
1503
-        $out = $this->db->prepare("SELECT id,name from arsse_labels where owner = ? and exists(select id from arsse_label_members where article = ? and label = arsse_labels.id and assigned = 1)", "str", "int")->run($user, $id)->getAll();
1508
+        $out = $this->db->prepare("SELECT id, name from arsse_labels join arsse_label_members on arsse_label_members.label = arsse_labels.id where owner = ? and article = ? and assigned = 1", "str", "int")->run($user, $id)->getAll();
1504 1509
         // flatten the result to return just the label ID or name, sorted
1505 1510
         $out = $out ? array_column($out, !$byName ? "id" : "name") : [];
1506 1511
         sort($out);
@@ -1525,30 +1530,16 @@ class Database {
1525 1530
     /** Deletes from the database articles which are beyond the configured clean-up threshold */
1526 1531
     public function articleCleanup(): bool {
1527 1532
         $query = $this->db->prepare(
1528
-            "WITH target_feed(id,subs) as (".
1529
-                "SELECT
1530
-                    id, (select count(*) from arsse_subscriptions where feed = arsse_feeds.id) as subs
1531
-                from arsse_feeds where id = ?".
1532
-            "), latest_editions(article,edition) as (".
1533
-                "SELECT article,max(id) from arsse_editions group by article".
1534
-            "), excepted_articles(id,edition) as (".
1535
-                "SELECT
1536
-                    arsse_articles.id as id,
1537
-                    latest_editions.edition as edition
1538
-                from arsse_articles
1539
-                    join target_feed on arsse_articles.feed = target_feed.id
1540
-                    join latest_editions on arsse_articles.id = latest_editions.article
1541
-                order by edition desc limit ?".
1542
-            ") ".
1543
-            "DELETE from arsse_articles where
1544
-                feed = (select max(id) from target_feed)
1545
-                and id not in (select id from excepted_articles)
1546
-                and (select count(*) from arsse_marks where article = arsse_articles.id and starred = 1) = 0
1547
-                and (
1548
-                    coalesce((select max(modified) from arsse_marks where article = arsse_articles.id),modified) <= ?
1549
-                    or ((select max(subs) from target_feed) = (select count(*) from arsse_marks where article = arsse_articles.id and \"read\" = 1) and coalesce((select max(modified) from arsse_marks where article = arsse_articles.id),modified) <= ?)
1533
+            "WITH RECURSIVE
1534
+                exempt_articles as (SELECT id from arsse_articles join (SELECT article, max(id) as edition from arsse_editions group by article) as latest_editions on arsse_articles.id = latest_editions.article where feed = ? order by edition desc limit ?),
1535
+                target_articles as (
1536
+                    select id from arsse_articles
1537
+                        left join (select article, sum(starred) as starred, sum(\"read\") as \"read\", max(arsse_marks.modified) as marked_date from arsse_marks join arsse_subscriptions on arsse_subscriptions.id = arsse_marks.subscription group by article) as mark_stats on mark_stats.article = arsse_articles.id
1538
+                        left join (select feed, count(*) as subs from arsse_subscriptions group by feed) as feed_stats on feed_stats.feed = arsse_articles.feed
1539
+                    where arsse_articles.feed = ? and coalesce(starred,0) = 0 and (coalesce(marked_date,modified) <= ? or (coalesce(\"read\",0) = coalesce(subs,0) and coalesce(marked_date,modified) <= ?))
1550 1540
                 )
1551
-            ",
1541
+            DELETE FROM arsse_articles WHERE id not in (select id from exempt_articles) and id in (select id from target_articles)",
1542
+            "int",
1552 1543
             "int",
1553 1544
             "int",
1554 1545
             "datetime",
@@ -1564,7 +1555,7 @@ class Database {
1564 1555
         }
1565 1556
         $feeds = $this->db->query("SELECT id, size from arsse_feeds")->getAll();
1566 1557
         foreach ($feeds as $feed) {
1567
-            $query->run($feed['id'], $feed['size'], $limitUnread, $limitRead);
1558
+            $query->run($feed['id'], $feed['size'], $feed['id'], $limitUnread, $limitRead);
1568 1559
         }
1569 1560
         return true;
1570 1561
     }
@@ -1574,21 +1565,19 @@ class Database {
1574 1565
      * Returns an associative array containing the id and latest edition of the article if it exists 
1575 1566
      * 
1576 1567
      * @param string $user The user who owns the article to be validated
1577
-     * @param integer|null $id The identifier of the article to validate
1568
+     * @param integer $id The identifier of the article to validate
1578 1569
      */
1579 1570
     protected function articleValidateId(string $user, $id): array {
1580 1571
         if (!ValueInfo::id($id)) {
1581 1572
             throw new Db\ExceptionInput("typeViolation", ["action" => $this->caller(), "field" => "article", 'type' => "int > 0"]); // @codeCoverageIgnore
1582 1573
         }
1583 1574
         $out = $this->db->prepare(
1584
-            "SELECT
1585
-                arsse_articles.id as article,
1586
-                (select max(id) from arsse_editions where article = arsse_articles.id) as edition
1587
-            FROM arsse_articles
1588
-                join arsse_feeds on arsse_feeds.id = arsse_articles.feed
1589
-                join arsse_subscriptions on arsse_subscriptions.feed = arsse_feeds.id
1590
-            WHERE
1591
-                arsse_articles.id = ? and arsse_subscriptions.owner = ?",
1575
+            "SELECT articles.article as article, max(arsse_editions.id)  as edition from (
1576
+                select arsse_articles.id as article
1577
+                FROM arsse_articles
1578
+                    join arsse_subscriptions on arsse_subscriptions.feed = arsse_articles.feed
1579
+                WHERE arsse_articles.id = ? and arsse_subscriptions.owner = ?
1580
+            ) as articles join arsse_editions on arsse_editions.article = articles.article group by articles.article",
1592 1581
             "int",
1593 1582
             "str"
1594 1583
         )->run($id, $user)->getRow();
@@ -1603,7 +1592,7 @@ class Database {
1603 1592
      * Returns an associative array containing the edition id, article id, and latest edition of the edition if it exists 
1604 1593
      * 
1605 1594
      * @param string $user The user who owns the edition to be validated
1606
-     * @param integer|null $id The identifier of the edition to validate
1595
+     * @param integer $id The identifier of the edition to validate
1607 1596
      */
1608 1597
     protected function articleValidateEdition(string $user, int $id): array {
1609 1598
         if (!ValueInfo::id($id)) {
@@ -1611,15 +1600,12 @@ class Database {
1611 1600
         }
1612 1601
         $out = $this->db->prepare(
1613 1602
             "SELECT
1614
-                arsse_editions.id as edition,
1615
-                arsse_editions.article as article,
1616
-                (arsse_editions.id = (select max(id) from arsse_editions where article = arsse_editions.article)) as current
1617
-            FROM arsse_editions
1618
-                join arsse_articles on arsse_editions.article = arsse_articles.id
1619
-                join arsse_feeds on arsse_feeds.id = arsse_articles.feed
1620
-                join arsse_subscriptions on arsse_subscriptions.feed = arsse_feeds.id
1621
-            WHERE
1622
-                arsse_editions.id = ? and arsse_subscriptions.owner = ?",
1603
+                arsse_editions.id, arsse_editions.article, edition_stats.edition as current
1604
+            from arsse_editions 
1605
+                join arsse_articles on arsse_articles.id = arsse_editions.article
1606
+                join arsse_subscriptions on arsse_subscriptions.feed = arsse_articles.feed
1607
+                join (select article, max(id) as edition from arsse_editions group by article) as edition_stats on edition_stats.article = arsse_editions.article
1608
+            where arsse_editions.id = ? and arsse_subscriptions.owner = ?",
1623 1609
             "int",
1624 1610
             "str"
1625 1611
         )->run($id, $user)->getRow();
@@ -1693,18 +1679,28 @@ class Database {
1693 1679
         return $this->db->prepare(
1694 1680
             "SELECT * FROM (
1695 1681
                 SELECT
1696
-                    id,name,
1697
-                    (select count(*) from arsse_label_members where label = id and assigned = 1) as articles,
1698
-                    (select count(*) from arsse_label_members
1699
-                        join arsse_marks on arsse_label_members.article = arsse_marks.article and arsse_label_members.subscription = arsse_marks.subscription
1700
-                    where label = id and assigned = 1 and \"read\" = 1
1701
-                    ) as \"read\"
1702
-                FROM arsse_labels where owner = ?) as label_data
1682
+                    id,name,coalesce(articles,0) as articles,coalesce(marked,0) as \"read\"
1683
+                from arsse_labels
1684
+                    left join (
1685
+                        SELECT label, sum(assigned) as articles from arsse_label_members group by label
1686
+                    ) as label_stats on label_stats.label = arsse_labels.id
1687
+                    left join (
1688
+                        SELECT 
1689
+                            label, sum(\"read\") as marked
1690
+                        from arsse_marks
1691
+                            join arsse_subscriptions on arsse_subscriptions.id = arsse_marks.subscription
1692
+                            join arsse_label_members on arsse_label_members.article = arsse_marks.article
1693
+                        where arsse_subscriptions.owner = ?
1694
+                        group by label
1695
+                    ) as mark_stats on mark_stats.label = arsse_labels.id
1696
+                WHERE owner = ?
1697
+            ) as label_data
1703 1698
             where articles >= ? order by name
1704 1699
             ",
1705 1700
             "str",
1701
+            "str",
1706 1702
             "int"
1707
-        )->run($user, !$includeEmpty);
1703
+        )->run($user, $user, !$includeEmpty);
1708 1704
     }
1709 1705
 
1710 1706
     /** Deletes a label from the database
@@ -1751,17 +1747,26 @@ class Database {
1751 1747
         $type = $byName ? "str" : "int";
1752 1748
         $out = $this->db->prepare(
1753 1749
             "SELECT
1754
-                id,name,
1755
-                (select count(*) from arsse_label_members where label = id and assigned = 1) as articles,
1756
-                (select count(*) from arsse_label_members
1757
-                    join arsse_marks on arsse_label_members.article = arsse_marks.article and arsse_label_members.subscription = arsse_marks.subscription
1758
-                 where label = id and assigned = 1 and \"read\" = 1
1759
-                ) as \"read\"
1760
-            FROM arsse_labels where $field = ? and owner = ?
1750
+                id,name,coalesce(articles,0) as articles,coalesce(marked,0) as \"read\"
1751
+            FROM arsse_labels
1752
+                left join (
1753
+                    SELECT label, sum(assigned) as articles from arsse_label_members group by label
1754
+                ) as label_stats on label_stats.label = arsse_labels.id
1755
+                left join (
1756
+                    SELECT 
1757
+                        label, sum(\"read\") as marked
1758
+                    from arsse_marks
1759
+                    join arsse_subscriptions on arsse_subscriptions.id = arsse_marks.subscription
1760
+                    join arsse_label_members on arsse_label_members.article = arsse_marks.article
1761
+                    where arsse_subscriptions.owner = ?
1762
+                    group by label
1763
+                ) as mark_stats on mark_stats.label = arsse_labels.id
1764
+            WHERE $field = ? and owner = ?
1761 1765
             ",
1766
+            "str",
1762 1767
             $type,
1763 1768
             "str"
1764
-        )->run($id, $user)->getRow();
1769
+        )->run($user, $id, $user)->getRow();
1765 1770
         if (!$out) {
1766 1771
             throw new Db\ExceptionInput("subjectMissing", ["action" => __FUNCTION__, "field" => "label", 'id' => $id]);
1767 1772
         }
@@ -1846,27 +1851,14 @@ class Database {
1846 1851
         $tr = $this->begin();
1847 1852
         // first update any existing entries with the removal or re-addition of their association
1848 1853
         $q = $this->articleQuery($user, $context);
1849
-        $q->setWhere("exists(select article from arsse_label_members where label = ? and article = arsse_articles.id)", "int", $id);
1850 1854
         $q->pushCTE("target_articles");
1851
-        $q->setBody(
1852
-            "UPDATE arsse_label_members set assigned = ?, modified = CURRENT_TIMESTAMP where label = ? and assigned <> ? and article in (select id from target_articles)",
1853
-            ["bool","int","bool"],
1854
-            [!$remove, $id, !$remove]
1855
-        );
1855
+        $q->setBody("UPDATE arsse_label_members set assigned = ?, modified = CURRENT_TIMESTAMP where label = ? and assigned <> ? and article in (select id from target_articles)", ["bool","int","bool"], [!$remove, $id, !$remove]);
1856 1856
         $out += $this->db->prepare($q->getQuery(), $q->getTypes())->run($q->getValues())->changes();
1857 1857
         // next, if we're not removing, add any new entries that need to be added
1858 1858
         if (!$remove) {
1859
-            $q = $this->articleQuery($user, $context, ["id", "feed"]);
1860
-            $q->setWhere("not exists(select article from arsse_label_members where label = ? and article = arsse_articles.id)", "int", $id);
1859
+            $q = $this->articleQuery($user, $context, ["id", "subscription"]);
1861 1860
             $q->pushCTE("target_articles");
1862
-            $q->setBody(
1863
-                "SELECT
1864
-                    ?,id,
1865
-                    (select id from arsse_subscriptions where owner = ? and arsse_subscriptions.feed = target_articles.feed)
1866
-                FROM target_articles",
1867
-                ["int", "str"],
1868
-                [$id, $user]
1869
-            );
1861
+            $q->setBody("SELECT ?,id,subscription from target_articles where id not in (select article from arsse_label_members where label = ?)", ["int", "int"], [$id, $id]);
1870 1862
             $out += $this->db->prepare("INSERT INTO arsse_label_members(label,article,subscription) ".$q->getQuery(), $q->getTypes())->run($q->getValues())->changes();
1871 1863
         }
1872 1864
         // commit the transaction

+ 53
- 10
tests/cases/Database/SeriesFolder.php View File

@@ -49,6 +49,49 @@ trait SeriesFolder {
49 49
                     [6, "john.doe@example.com",    2, "Politics"],
50 50
                 ]
51 51
             ],
52
+            'arsse_feeds' => [
53
+                'columns' => [
54
+                    'id'         => "int",
55
+                    'url'        => "str",
56
+                    'title'      => "str",
57
+                ],
58
+                'rows' => [
59
+                    [1,"http://example.com/1", "Feed 1"],
60
+                    [2,"http://example.com/2", "Feed 2"],
61
+                    [3,"http://example.com/3", "Feed 3"],
62
+                    [4,"http://example.com/4", "Feed 4"],
63
+                    [5,"http://example.com/5", "Feed 5"],
64
+                    [6,"http://example.com/6", "Feed 6"],
65
+                    [7,"http://example.com/7", "Feed 7"],
66
+                    [8,"http://example.com/8", "Feed 8"],
67
+                    [9,"http://example.com/9", "Feed 9"],
68
+                    [10,"http://example.com/10", "Feed 10"],
69
+                    [11,"http://example.com/11", "Feed 11"],
70
+                    [12,"http://example.com/12", "Feed 12"],
71
+                    [13,"http://example.com/13", "Feed 13"],
72
+                ]
73
+            ],
74
+            'arsse_subscriptions' => [
75
+                'columns' => [
76
+                    'id'         => "int",
77
+                    'owner'      => "str",
78
+                    'feed'       => "int",
79
+                    'folder'     => "int",
80
+                ],
81
+                'rows' => [
82
+                    [1, "john.doe@example.com",1, null],
83
+                    [2, "john.doe@example.com",2, null],
84
+                    [3, "john.doe@example.com",3,    1],
85
+                    [4, "john.doe@example.com",4,    6],
86
+                    [5, "john.doe@example.com",5,    5],
87
+                    [6, "john.doe@example.com",10,   5],
88
+                    [7, "jane.doe@example.com",1, null],
89
+                    [8, "jane.doe@example.com",10,null],
90
+                    [9, "jane.doe@example.com",2,    4],
91
+                    [10,"jane.doe@example.com",3,    4],
92
+                    [11,"jane.doe@example.com",4,    4],
93
+                ]
94
+            ],
52 95
         ];
53 96
     }
54 97
 
@@ -119,8 +162,8 @@ trait SeriesFolder {
119 162
 
120 163
     public function testListRootFolders() {
121 164
         $exp = [
122
-            ['id' => 5, 'name' => "Politics",   'parent' => null, 'children' => 0],
123
-            ['id' => 1, 'name' => "Technology", 'parent' => null, 'children' => 2],
165
+            ['id' => 5, 'name' => "Politics",   'parent' => null, 'children' => 0, 'feeds' => 2],
166
+            ['id' => 1, 'name' => "Technology", 'parent' => null, 'children' => 2, 'feeds' => 1],
124 167
         ];
125 168
         $this->assertResult($exp, Arsse::$db->folderList("john.doe@example.com", null, false));
126 169
         $exp = [
@@ -136,17 +179,17 @@ trait SeriesFolder {
136 179
 
137 180
     public function testListFoldersRecursively() {
138 181
         $exp = [
139
-            ['id' => 5, 'name' => "Politics",   'parent' => null, 'children' => 0],
140
-            ['id' => 6, 'name' => "Politics",   'parent' => 2, 'children' => 0],
141
-            ['id' => 3, 'name' => "Rocketry",   'parent' => 1, 'children' => 0],
142
-            ['id' => 2, 'name' => "Software",   'parent' => 1, 'children' => 1],
143
-            ['id' => 1, 'name' => "Technology", 'parent' => null, 'children' => 2],
182
+            ['id' => 5, 'name' => "Politics",   'parent' => null, 'children' => 0, 'feeds' => 2],
183
+            ['id' => 6, 'name' => "Politics",   'parent' => 2,    'children' => 0, 'feeds' => 1],
184
+            ['id' => 3, 'name' => "Rocketry",   'parent' => 1,    'children' => 0, 'feeds' => 0],
185
+            ['id' => 2, 'name' => "Software",   'parent' => 1,    'children' => 1, 'feeds' => 0],
186
+            ['id' => 1, 'name' => "Technology", 'parent' => null, 'children' => 2, 'feeds' => 1],
144 187
         ];
145 188
         $this->assertResult($exp, Arsse::$db->folderList("john.doe@example.com", null, true));
146 189
         $exp = [
147
-            ['id' => 6, 'name' => "Politics",   'parent' => 2, 'children' => 0],
148
-            ['id' => 3, 'name' => "Rocketry",   'parent' => 1, 'children' => 0],
149
-            ['id' => 2, 'name' => "Software",   'parent' => 1, 'children' => 1],
190
+            ['id' => 6, 'name' => "Politics",   'parent' => 2, 'children' => 0, 'feeds' => 1],
191
+            ['id' => 3, 'name' => "Rocketry",   'parent' => 1, 'children' => 0, 'feeds' => 0],
192
+            ['id' => 2, 'name' => "Software",   'parent' => 1, 'children' => 1, 'feeds' => 0],
150 193
         ];
151 194
         $this->assertResult($exp, Arsse::$db->folderList("john.doe@example.com", 1, true));
152 195
         $exp = [];

Loading…
Cancel
Save