Make readBy and unreadBy random
This commit is contained in:
parent
f56e7e29df
commit
04e11925ac
2 changed files with 13 additions and 2 deletions
|
@ -2,6 +2,7 @@ const express = require('express');
|
|||
const router = express.Router();
|
||||
const protocol = require('../utils/connection');
|
||||
const converter = require('../utils/converter');
|
||||
const {getRandomInt} = require("../utils/api");
|
||||
const md5 = require('md5');
|
||||
|
||||
router.get("/", (req, res) => {
|
||||
|
@ -38,14 +39,17 @@ router.get("/-endpoints", (req, res) => {
|
|||
});
|
||||
|
||||
router.get("/Wiadomosc.mvc/GetInboxMessages", (req, res) => {
|
||||
const recipientsNumber = getRandomInt(60, 100);
|
||||
const readBy = getRandomInt(20, 60);
|
||||
const unreadBy = recipientsNumber - readBy;
|
||||
res.json({
|
||||
"success": true,
|
||||
"data": require("../../data/api/messages/WiadomosciOdebrane").map(item => {
|
||||
return {
|
||||
"Id": item.WiadomoscId * 2,
|
||||
"Nieprzeczytana": !item.GodzinaPrzeczytania,
|
||||
"Nieprzeczytane": 0,
|
||||
"Przeczytane": 1,
|
||||
"Nieprzeczytane": unreadBy,
|
||||
"Przeczytane": readBy,
|
||||
"Data": converter.formatDate(new Date(item.DataWyslaniaUnixEpoch * 1000), true) + ' 00:00:00',
|
||||
"Tresc": null,
|
||||
"Temat": item.Tytul,
|
||||
|
|
|
@ -12,4 +12,11 @@ function createResponse(data) {
|
|||
};
|
||||
}
|
||||
|
||||
function getRandomInt(min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min)) + min;
|
||||
}
|
||||
|
||||
exports.createResponse = createResponse;
|
||||
exports.getRandomInt = getRandomInt;
|
||||
|
|
Loading…
Reference in a new issue