Small fixes to get started

- docker-compose needs the flag --build to (re)build all containers
- Initially, on an empty database, Track.aggregate returns an empty array,
  which results in an undefined error for /api/stats
This commit is contained in:
Dennis Boldt 2021-04-26 22:12:07 +02:00
parent 840ecc6d6f
commit e9ea0645c9
3 changed files with 48 additions and 11671 deletions

View file

@ -10,6 +10,15 @@ separated into components:
provides summaries and visualizations, and lets users adjust settings and provides summaries and visualizations, and lets users adjust settings and
manage and publish their tracks. manage and publish their tracks.
## Clone the Project
First of all, you must clone this project. This project uses submodules,
thus ensure, that they are cloned as well:
```bash
git submodule update --init --recursive
```
## Deployment setup ## Deployment setup
You should be familiar with managing a Linux server. If not, find a suitable You should be familiar with managing a Linux server. If not, find a suitable
@ -48,7 +57,7 @@ Compose](https://docs.docker.com/compose/install/) onto your machine, and
cloning the repository, all you need to do is: cloning the repository, all you need to do is:
```bash ```bash
docker-compose up -d docker-compose up -d --build
``` ```
If this does not work, please open an issue and describe the problem you're If this does not work, please open an issue and describe the problem you're

11702
api/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,7 @@ router.get(
const publicTrackCount = await Track.find({ public: true }).count(); const publicTrackCount = await Track.find({ public: true }).count();
const userCount = await User.find().count(); const userCount = await User.find().count();
const [{ trackLength, numEvents, trackDuration }] = await Track.aggregate([ const aggregateResult = await Track.aggregate([
{ {
$addFields: { $addFields: {
trackLength: '$statistics.length', trackLength: '$statistics.length',
@ -39,6 +39,8 @@ router.get(
}, },
]); ]);
const [trackLength, numEvents, trackDuration] = aggregateResult.length > 0 ? aggregateResult : [0,0,0];
const trackLengthPrivatized = Math.floor(trackLength / TRACK_LENGTH_ROUNDING) * TRACK_LENGTH_ROUNDING; const trackLengthPrivatized = Math.floor(trackLength / TRACK_LENGTH_ROUNDING) * TRACK_LENGTH_ROUNDING;
return res.json({ return res.json({