feat(postgres): added GetUserFavoriteCount
This commit is contained in:
parent
c04e382ee5
commit
4f8e54f09a
@ -59,3 +59,21 @@ func CreateUserNodeWithSourceRelation(ctx context.Context, db *gorm.DB, anthrove
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserFavoritesCount(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID) (int64, error) {
|
||||||
|
var count int64
|
||||||
|
err := db.WithContext(ctx).Model(&pgModels.UserFavorite{}).Where("user_id = ?", string(anthroveUserID)).Count(&count).Error
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"anthrove_user_id": anthroveUserID,
|
||||||
|
}).Error("database: failed to get user favorites count")
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"anthrove_user_id": anthroveUserID,
|
||||||
|
"anthrove_user_fav_count": count,
|
||||||
|
}).Trace("database: got user favorite count")
|
||||||
|
|
||||||
|
return count, nil
|
||||||
|
}
|
||||||
|
@ -102,8 +102,7 @@ func (p *postgresqlConnection) CheckPostNodeExistsBySourceID(ctx context.Context
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *postgresqlConnection) GetUserFavoriteCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error) {
|
func (p *postgresqlConnection) GetUserFavoriteCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error) {
|
||||||
//TODO implement me
|
return postgres.GetUserFavoritesCount(ctx, p.db, anthroveUserID)
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *postgresqlConnection) GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]graphModels.AnthroveUserRelationship, error) {
|
func (p *postgresqlConnection) GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]graphModels.AnthroveUserRelationship, error) {
|
||||||
|
Reference in New Issue
Block a user