Merge branch 'master' into feat/history-router
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
const path = require('path');
|
||||
|
||||
const mongoose = require('mongoose');
|
||||
mongoose.connect('mongodb://localhost:27017/vinlottis', {
|
||||
useNewUrlParser: true
|
||||
})
|
||||
|
||||
const Highscore = require(path.join(__dirname + '/../schemas/Highscore'));
|
||||
const Wine = require(path.join(__dirname + '/../schemas/Wine'));
|
||||
|
||||
@@ -82,11 +77,13 @@ const byEpochDate = (req, res) => {
|
||||
.then(highscore => getHighscoreByDates(highscore))
|
||||
.then(async (lotteries) => {
|
||||
const lottery = lotteries[date];
|
||||
let highscoreWithResolvedWines = await resolveWineReferences(lottery)
|
||||
highscoreWithResolvedWines = highscoreWithResolvedWines.reverse()
|
||||
|
||||
if (lottery != null) {
|
||||
return res.send({
|
||||
message: `Lottery for date: ${dateString}`,
|
||||
lottery: await resolveWineReferences(lottery)
|
||||
lottery: highscoreWithResolvedWines
|
||||
})
|
||||
} else {
|
||||
return res.status(404).send({
|
||||
@@ -98,15 +95,18 @@ const byEpochDate = (req, res) => {
|
||||
|
||||
const byName = (req, res) => {
|
||||
const { name } = req.params;
|
||||
const regexName = new RegExp(name, "i"); // lowercase regex of the name
|
||||
|
||||
return Highscore.find({ name })
|
||||
return Highscore.find({ "name": { $regex : regexName } })
|
||||
.then(async (highscore) => {
|
||||
highscore = highscore[0]
|
||||
if (highscore) {
|
||||
const highscoreWithResolvedWines = await resolveWineReferences(highscore.wins)
|
||||
let highscoreWithResolvedWines = await resolveWineReferences(highscore.wins)
|
||||
highscoreWithResolvedWines = highscoreWithResolvedWines.reverse()
|
||||
|
||||
return res.send({
|
||||
message: `Lottery winnings by name: ${name}`,
|
||||
name: name,
|
||||
highscore: highscoreWithResolvedWines
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
const path = require("path");
|
||||
const mongoose = require("mongoose");
|
||||
mongoose.connect("mongodb://localhost:27017/vinlottis", {
|
||||
useNewUrlParser: true
|
||||
});
|
||||
|
||||
const Purchase = require(path.join(__dirname + "/../schemas/Purchase"));
|
||||
const Wine = require(path.join(__dirname + "/../schemas/Wine"));
|
||||
|
||||
@@ -2,13 +2,8 @@ const express = require("express");
|
||||
const path = require("path");
|
||||
const router = express.Router();
|
||||
const webpush = require("web-push"); //requiring the web-push module
|
||||
const mongoose = require("mongoose");
|
||||
const schedule = require("node-schedule");
|
||||
|
||||
mongoose.connect("mongodb://localhost:27017/vinlottis", {
|
||||
useNewUrlParser: true
|
||||
});
|
||||
|
||||
const mustBeAuthenticated = require(path.join(
|
||||
__dirname + "/../middleware/mustBeAuthenticated"
|
||||
));
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
const mongoose = require("mongoose");
|
||||
mongoose.connect("mongodb://localhost:27017/vinlottis", {
|
||||
useNewUrlParser: true
|
||||
});
|
||||
|
||||
const sub = require(path.join(__dirname + "/../api/subscriptions"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user