プロジェクト

全般

プロフィール

Bug(バグ) #2614

コミュニティ参加人数ランキングページに表示される参加人数に、参加申請承認待ちのメンバーが含まれている

Minoru Takai12年以上前に追加.

ステータス:
New(新規)
優先度:
Normal(通常)
担当者:
-
開始日:
2011-11-18
期日:
進捗率:

0%

3.6 で発生するか:
[QA]バグ通知済:
いいえ
3.8 で発生するか:
Unknown (未調査)

説明

概要

コミュニティ参加人数ランキングページ(添付画像参照)には「第1位 commu1 :5人」「第2位 commu2 :1人」のように、ランキングとコミュニティ名、参加人数が表示されるが、「参加人数」に参加申請承認待ちのメンバーが含まれてしまっている。

対象バージョン

#2601 と同様だが、全てのバージョンで生じる問題かと思われる( v0.9.0 で実装された部分なので、それ以降のバージョン全て http://plugins.openpne.jp/package/opRankingPlugin/releases )。

少なくとも OpenPNE-3.6.0 にバンドルされる v1.0.1 で生じている。

原因

https://github.com/tejimaya/opRankingPlugin/blob/v1.0.1/lib/opRankingPlugin.php#L98 では、ランキングに対して参加人数が多い順に結果を取得している。

    $communityMembers = Doctrine::getTable('CommunityMember')->createQuery()
      ->select('COUNT(*), community_id')
      ->groupBy('community_id')
      ->orderBy('COUNT(*) DESC')
      ->offset($page * $max)
      ->limit($max)
      ->fetchArray();

これで取得できる値は次のようなもの。

array
  0 => 
    array
      'id' => string '1' (length=1)
      'community_id' => string '1' (length=1)
      'COUNT' => string '5' (length=1)
  1 => 
    array
      'id' => string '2' (length=1)
      'community_id' => string '2' (length=1)
      'COUNT' => string '1' (length=1)

ここで id は意味のない値であり、 community_id が「コミュニティ」のIDであり、 COUNT が「参加人数」である。

しかし、上記の結果を出力したときの DB は次のようになっている。

mysql> select * from community;
+----+--------+---------+-----------------------+---------------------+---------------------+
| id | name   | file_id | community_category_id | created_at          | updated_at          |
+----+--------+---------+-----------------------+---------------------+---------------------+
|  1 | commu1 |    NULL |                  NULL | 2011-11-18 19:06:30 | 2011-11-18 19:06:30 | 
|  2 | commu2 |    NULL |                  NULL | 2011-11-18 19:06:57 | 2011-11-18 19:06:57 | 
+----+--------+---------+-----------------------+---------------------+---------------------+
2 rows in set (0.00 sec)

mysql> select * from community_member;
+----+--------------+-----------+--------+--------------------+------------------------+---------------------+---------------------+
| id | community_id | member_id | is_pre | is_receive_mail_pc | is_receive_mail_mobile | created_at          | updated_at          |
+----+--------------+-----------+--------+--------------------+------------------------+---------------------+---------------------+
|  1 |            1 |         1 |      0 |                  0 |                      0 | 2011-11-18 19:06:30 | 2011-11-18 19:06:30 | 
|  2 |            2 |         1 |      0 |                  0 |                      0 | 2011-11-18 19:06:57 | 2011-11-18 19:06:57 | 
|  3 |            1 |         6 |      0 |                  0 |                      0 | 2011-11-18 19:11:31 | 2011-11-18 19:11:31 | 
|  4 |            1 |         7 |      0 |                  0 |                      0 | 2011-11-18 19:11:47 | 2011-11-18 19:11:47 | 
|  5 |            1 |         8 |      1 |                  0 |                      0 | 2011-11-18 19:19:25 | 2011-11-18 19:19:25 | 
|  6 |            1 |         9 |      1 |                  0 |                      0 | 2011-11-18 19:35:19 | 2011-11-18 19:35:19 | 
+----+--------------+-----------+--------+--------------------+------------------------+---------------------+---------------------+
6 rows in set (0.00 sec)

  • commu1, commu2 が存在している
  • commu2 に member1 だけが参加している
  • commu1 に member1, 6, 7 の 3 人が参加しており、 8, 9 の 2 人が参加申請をしている

参加人数を取得する際に、参加申請中であるかどうかを確認していない。

次の条件が必要である。

  • where('is_pre = ?', false)
    • 参加申請中ではなく、参加済みのメンバーに限る

修正方針

原因に示した通り、「参加申請中ではなく、参加済みのメンバーに限る」という条件を加える必要がある。

  • 原因に示した条件を単に追加した差分
    diff --git a/lib/opRankingPlugin.php b/lib/opRankingPlugin.php
    index b0a1066..48e9e73 100644
    --- a/lib/opRankingPlugin.php
    +++ b/lib/opRankingPlugin.php
    @@ -100,6 +100,7 @@ class opRankingPlugin
       {
         $communityMembers = Doctrine::getTable('CommunityMember')->createQuery()
           ->select('COUNT(*), community_id')
    +      ->where('is_pre = ?', false)
           ->groupBy('community_id')
           ->orderBy('COUNT(*) DESC')
           ->offset($page * $max)
    

commu_ranking_before.png 表示 (120 KB) Minoru Takai, 2011-11-18 20:00


関連するチケット

関連している opRankingPlugin - Bug(バグ) #2601: フレンド数ランキングページに表示されるフレンド数に、招待中のメンバーが含まれている New(新規) 2011-11-16
関連している opRankingPlugin - Enhancement(機能追加・改善) #2615: フレンド数ランキングとコミュニティ参加人数ランキングの処理で DQL 周りのコードが一部適切でない New(新規) 2011-11-18

他の形式にエクスポート: Atom PDF