How to use decay algorithm for sorting photos in Express?

Viewed 38

I am trying to sort my posts by the best response of users using https://github.com/clux/decay algorithms in Express and Angular.

PhotoController

    listhot: function (req, res) {
        photoModel.find(function (err, photos) {
            if (err) {
                return res.status(500).json({
                    message: 'Error when getting photo.',
                    error: err
                });
            }
            return res.json(photos);
        });
    }

hot-photos.component.html

<div *ngFor="let photo of photos.slice().reverse()" [routerLink]="['/photo',photo._id]">
  <h5 class="card-title">Naslov: {{photo.name}}</h5>
  <h5> Objavil: {{ photo.username}} </h5>
  <img class="card-img" src="{{photoHost+photo.path}}" alt="{{photo.name}}">
  <div class="card-img-bottom">
    <h5 class="card-title"><a><i class="fas fa-heart text-danger"></i></a>
      {{photo.likes}} <a><i class="fas fa-comment-dots text-secondary"></i></a> {{photo.comments?.length}}</h5>
  </div>
  <hr />

My goal is to sort the images.

0 Answers
Related