public static function podiumMarkAllSeen()
    {
        try {
            $loggedId = User::loggedId();
            if (empty($loggedId)) {
                throw new Exception('User ID missing');
            }
            $updateBatch = [];
            $threadsPrevMarked = Thread::find()->joinWith(['threadView' => function ($q) use ($loggedId) {
                $q->onCondition(['user_id' => $loggedId]);
                $q->andWhere(['or',
                        new Expression('new_last_seen < new_post_at'),
                        new Expression('edited_last_seen < edited_post_at'),
                    ]);
            }], false);
            $time = time();
            foreach ($threadsPrevMarked->each() as $thread) {
                $updateBatch[] = $thread->id;
            }
            if (!empty($updateBatch)) {
                Podium::getInstance()->db->createCommand()->update(ThreadView::tableName(), [
                    'new_last_seen' => $time,
                    'edited_last_seen' => $time
                ], ['thread_id' => $updateBatch, 'user_id' => $loggedId])->execute();
            }

            $insertBatch = [];
            $threadsNew = Thread::find()->joinWith(['threadView' => function ($q) use ($loggedId) {
                $q->onCondition(['user_id' => $loggedId]);
                $q->andWhere(['new_last_seen' => null]);
            }], false);
            foreach ($threadsNew->each() as $thread) {
                $insertBatch[] = [$loggedId, $thread->id, $time, $time];
            }
            if (!empty($insertBatch)) {
                Podium::getInstance()->db->createCommand()->batchInsert(ThreadView::tableName(), [
                    'user_id', 'thread_id', 'new_last_seen', 'edited_last_seen'
                ], $insertBatch)->execute();
            }
            return true;
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
public static function podiumMarkAllSeen()
    {
        try {
            $loggedId = User::loggedId();
            if (empty($loggedId)) {
                throw new Exception('User ID missing');
            }
            $updateBatch = [];
            $threadsPrevMarked = Thread::find()->joinWith(['threadView' => function ($q) use ($loggedId) {
                $q->onCondition(['user_id' => $loggedId]);
                $q->andWhere(['or',
                        new Expression('new_last_seen < new_post_at'),
                        new Expression('edited_last_seen < edited_post_at'),
                    ]);
            }], false);
            $time = time();
            foreach ($threadsPrevMarked->each() as $thread) {
                $updateBatch[] = $thread->id;
            }
            if (!empty($updateBatch)) {
                Podium::getInstance()->db->createCommand()->update(ThreadView::tableName(), [
                    'new_last_seen' => $time,
                    'edited_last_seen' => $time
                ], ['thread_id' => $updateBatch, 'user_id' => $loggedId])->execute();
            }

            $insertBatch = [];
            $threadsNew = Thread::find()->joinWith(['threadView' => function ($q) use ($loggedId) {
                $q->onCondition(['user_id' => $loggedId]);
                $q->andWhere(['new_last_seen' => null]);
            }], false);
            foreach ($threadsNew->each() as $thread) {
                $insertBatch[] = [$loggedId, $thread->id, $time, $time];
            }
            if (!empty($insertBatch)) {
                Podium::getInstance()->db->createCommand()->batchInsert(ThreadView::tableName(), [
                    'user_id', 'thread_id', 'new_last_seen', 'edited_last_seen'
                ], $insertBatch)->execute();
            }
            return true;
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
public static function podiumMarkAllSeen ( ) { try { $ loggedId = User :: loggedId ( ) ; if ( empty ( $ loggedId ) ) { throw new Exception ( 'User ID missing' ) ; } $ updateBatch = [ ] ; $ threadsPrevMarked = Thread :: find ( ) -> joinWith ( [ 'threadView' => function ( $ q ) use ( $ loggedId ) { $ q -> onCondition ( [ 'user_id' => $ loggedId ] ) ; $ q -> andWhere ( [ 'or' , new Expression ( 'new_last_seen < new_post_at' ) , new Expression ( 'edited_last_seen < edited_post_at' ) , ] ) ; } ] , false ) ; $ time = time ( ) ; foreach ( $ threadsPrevMarked -> each ( ) as $ thread ) { $ updateBatch [ ] = $ thread -> id ; } if ( ! empty ( $ updateBatch ) ) { Podium :: getInstance ( ) -> db -> createCommand ( ) -> update ( ThreadView :: tableName ( ) , [ 'new_last_seen' => $ time , 'edited_last_seen' => $ time ] , [ 'thread_id' => $ updateBatch , 'user_id' => $ loggedId ] ) -> execute ( ) ; } $ insertBatch = [ ] ; $ threadsNew = Thread :: find ( ) -> joinWith ( [ 'threadView' => function ( $ q ) use ( $ loggedId ) { $ q -> onCondition ( [ 'user_id' => $ loggedId ] ) ; $ q -> andWhere ( [ 'new_last_seen' => null ] ) ; } ] , false ) ; foreach ( $ threadsNew -> each ( ) as $ thread ) { $ insertBatch [ ] = [ $ loggedId , $ thread -> id , $ time , $ time ] ; } if ( ! empty ( $ insertBatch ) ) { Podium :: getInstance ( ) -> db -> createCommand ( ) -> batchInsert ( ThreadView :: tableName ( ) , [ 'user_id' , 'thread_id' , 'new_last_seen' , 'edited_last_seen' ] , $ insertBatch ) -> execute ( ) ; } return true ; } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Performs marking all unread threads as seen for user.
@return bool
@throws Exception
@since 0.2
Performs marking all unread threads as seen for user .