Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 280 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 280 Rev 1323
Línea 148... Línea 148...
148
       $paginator->setCurrentPageNumber($page);
148
       $paginator->setCurrentPageNumber($page);
Línea 149... Línea 149...
149
       
149
       
150
       
150
       
-
 
151
       return $paginator;
-
 
152
   }
-
 
153
   
-
 
154
   /**
-
 
155
    * 
-
 
156
    * @param int $company_id
-
 
157
    * @param int $topic_id
-
 
158
    * @param int $capsule_id
-
 
159
    * @param int $user_id
-
 
160
    * @return void|CompanyMicrolearningCapsuleComment
-
 
161
    */
-
 
162
   public function fetchOneByCompanyIdAndTopicIdAndCapsuleIdAndUserId($company_id, $topic_id, $capsule_id, $user_id)
-
 
163
   {
-
 
164
       $select = $this->sql->select();
-
 
165
       $select->from(self::_TABLE);
-
 
166
       $select->where->equalTo('company_id', $company_id);
-
 
167
       $select->where->equalTo('topic_id', $topic_id);
-
 
168
       $select->where->equalTo('capsule_id', $capsule_id);
-
 
169
       $select->where->equalTo('user_id', $user_id);
-
 
170
       
-
 
171
       $prototype = new CompanyMicrolearningCapsuleComment();
-
 
172
       return $this->executeFetchOneObject($select, $prototype);
-
 
173
   }
-
 
174
   
-
 
175
   /**
-
 
176
    * 
-
 
177
    * @param int $company_id
-
 
178
    * @param int $topic_id
-
 
179
    * @param int $capsule_id
-
 
180
    * @return number[]
-
 
181
    */
-
 
182
   public function fetchCountAndRatingAverage($company_id, $topic_id, $capsule_id)
-
 
183
   {
-
 
184
       $select = $this->sql->select();
-
 
185
       $select->columns(['qty' => new Expression('COUNT(*)'), 'rating' ]);
-
 
186
       $select->from(self::_TABLE);
-
 
187
       $select->where->equalTo('company_id', $company_id);
-
 
188
       $select->where->equalTo('topic_id', $topic_id);
-
 
189
       $select->where->equalTo('capsule_id', $capsule_id);
-
 
190
    
-
 
191
       $total_comments  = 0;
-
 
192
       $total_rating = 0;
-
 
193
       
-
 
194
       $records = $this->executeFetchAllArray($select);
-
 
195
       foreach($records as $record)
-
 
196
       {
-
 
197
           $total_comments += $record['qty'];
-
 
198
           $total_rating += ($record['qty'] * $record['rating']);
-
 
199
       }
-
 
200
       
-
 
201
       return  [
-
 
202
           'total_comments' => $total_comments,
-
 
203
           'total_rating'  => $total_comments > 0 ? round($total_rating / $total_comments) : 0,
-
 
204
       ];
Línea 151... Línea 205...
151
       return $paginator;
205
       
152
   }
206
   }
153
    
207
    
Línea 213... Línea 267...
213
     * @param int $id
267
     * @param int $id
214
     * @return boolean
268
     * @return boolean
215
     */
269
     */
216
    public function delete($id)
270
    public function delete($id)
217
    {
271
    {
218
        $delete = $this->sql->delte(self::_TABLE);
272
        $delete = $this->sql->delete(self::_TABLE);
219
        $delete->where->equalTo('id', $id);
273
        $delete->where->equalTo('id', $id);
Línea 220... Línea 274...
220
        
274
        
221
        return $this->executeDelete($delete);
275
        return $this->executeDelete($delete);