diff --git a/app/pages/home/Table.js b/app/pages/home/Table.js index eeba12f..2d0974a 100644 --- a/app/pages/home/Table.js +++ b/app/pages/home/Table.js @@ -7,8 +7,7 @@ export default class Table extends Component { super() this.scanResults = scanResults.map(row => ({ ...row, - id: row._id, - difference: row.setPrice - row.partsPrice + id: row._id })) this.columns = [ { @@ -16,7 +15,15 @@ export default class Table extends Component { headerName: 'Name', flex: 1, renderCell: (cellValues) => { - return {cellValues.row.name} + return ( + + {cellValues.row.fullName} + + ) } }, { diff --git a/gather/src/index.js b/gather/src/index.js index 32bbb84..0a32310 100644 --- a/gather/src/index.js +++ b/gather/src/index.js @@ -19,13 +19,18 @@ async function initDB () { } const setPrice = await item.set.getPrice() - if (partsPrice < setPrice) { - models.ScanResult.findOneAndUpdate( - { name: item.name }, - { partsPrice, setPrice }, - { upsert: true }, - () => {} - ) - } + models.ScanResult.findOneAndUpdate( + { name: item.name }, + { + fullName: item.fullName, + url: item.set.url, + timestamp: new Date(), + partsPrice, + setPrice, + difference: setPrice - partsPrice + }, + { upsert: true }, + () => {} + ) } })() diff --git a/gather/src/items/Item.js b/gather/src/items/Item.js index 494f226..0b79ccb 100644 --- a/gather/src/items/Item.js +++ b/gather/src/items/Item.js @@ -1,8 +1,13 @@ const Part = require('./Part') +function capitalize (string) { + return string.charAt(0).toUpperCase() + string.slice(1) +} + module.exports = class Item { constructor (name) { this.name = name + this.fullName = capitalize(name) + ' Prime' this.set = new Part(name, 'set') this.parts = [] diff --git a/gather/src/items/Part.js b/gather/src/items/Part.js index 975b1df..a1db718 100644 --- a/gather/src/items/Part.js +++ b/gather/src/items/Part.js @@ -3,12 +3,13 @@ const Api = require('../api') module.exports = class Part { constructor (set, part, amount) { this.part = part - this.url = `${set}_prime_${part}` + this.urlPath = `${set}_prime_${part}` + this.url = `https://warframe.market/items/${set}_prime_${part}` this.amount = amount ?? 1 } async getPrice () { - const orders = await Api.getSortedOrders(this.url) + const orders = await Api.getSortedOrders(this.urlPath) return Number(orders[0].platinum) * this.amount } } diff --git a/shared-stuff/models/ScanResult.js b/shared-stuff/models/ScanResult.js index b324e92..6fcf73c 100644 --- a/shared-stuff/models/ScanResult.js +++ b/shared-stuff/models/ScanResult.js @@ -2,8 +2,14 @@ const mongoose = require('mongoose') const scanResultSchema = new mongoose.Schema({ name: String, + fullName: String, + url: String, partsPrice: Number, - setPrice: Number + setPrice: Number, + difference: Number +}, +{ + timestamps: true }) module.exports = mongoose.models.ScanResult || mongoose.model('ScanResult', scanResultSchema)