add page for items with bugged listing metric
This commit is contained in:
parent
3a665442bc
commit
b7e9c3a60d
|
@ -458,9 +458,9 @@ func itemsListHandler(w http.ResponseWriter, _ *http.Request) {
|
|||
func staleItemsListHandler(w http.ResponseWriter, _ *http.Request) {
|
||||
// Remap our data into a smaller object, we don't need full data for the front end
|
||||
type ResponseDataItem struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
LastUpdated string `json:"lastupdated"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
var responseDataItemSlice []MarketItem
|
||||
for _, item := range items {
|
||||
|
@ -486,9 +486,56 @@ func staleItemsListHandler(w http.ResponseWriter, _ *http.Request) {
|
|||
|
||||
for _, item := range responseDataItemSlice {
|
||||
responseDataItem := ResponseDataItem{
|
||||
ID: item.ID,
|
||||
Name: item.Name,
|
||||
LastUpdated: time.Unix(item.MarketBoardListing.LastUploadTime/1000, 0).Format("2006-01-02"),
|
||||
ID: item.ID,
|
||||
Name: item.Name,
|
||||
Data: time.Unix(item.MarketBoardListing.LastUploadTime/1000, 0).Format("2006-01-02"),
|
||||
}
|
||||
responseData = append(responseData, responseDataItem)
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(responseData)
|
||||
if err != nil {
|
||||
log.Printf("itemsListHandler failed to marshal json to bytes: %v", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Write(jsonBytes)
|
||||
}
|
||||
|
||||
// http - GET /bugged-metric-items-list
|
||||
// Returns a list of
|
||||
func buggedMetricItemsListHandler(w http.ResponseWriter, _ *http.Request) {
|
||||
// Remap our data into a smaller object, we don't need full data for the front end
|
||||
type ResponseDataItem struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
var responseDataItemSlice []MarketItem
|
||||
for _, item := range items {
|
||||
if item.ListingMetric != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
responseDataItemSlice = append(responseDataItemSlice, *(items[item.ID]))
|
||||
}
|
||||
|
||||
// Sort the item slice by time last updated
|
||||
sort.Slice(responseDataItemSlice, func(i, j int) bool {
|
||||
return responseDataItemSlice[i].MarketBoardListing.LastUploadTime < responseDataItemSlice[j].MarketBoardListing.LastUploadTime
|
||||
})
|
||||
|
||||
if len(responseDataItemSlice) > 600 {
|
||||
responseDataItemSlice = responseDataItemSlice[:600] // truncate to top 600
|
||||
}
|
||||
|
||||
responseData := make([]ResponseDataItem, 0)
|
||||
|
||||
for _, item := range responseDataItemSlice {
|
||||
responseDataItem := ResponseDataItem{
|
||||
ID: item.ID,
|
||||
Name: item.Name,
|
||||
Data: time.Unix(item.MarketBoardListing.LastUploadTime/1000, 0).Format("2006-01-02"),
|
||||
}
|
||||
responseData = append(responseData, responseDataItem)
|
||||
}
|
||||
|
|
1
main.go
1
main.go
|
@ -220,6 +220,7 @@ func main() {
|
|||
http.HandleFunc("/price-update", singlePriceUpdateHandler)
|
||||
http.HandleFunc("/status", statusHandler)
|
||||
http.HandleFunc("/items-list", itemsListHandler)
|
||||
http.HandleFunc("/bugged-metric-items-list", buggedMetricItemsListHandler)
|
||||
http.HandleFunc("/stale-items-list", staleItemsListHandler)
|
||||
http.HandleFunc("/search-listing-retainer", searchListingRetainerHandler)
|
||||
http.HandleFunc("/search-listing-craftedby", searchListingCraftedbyHandler)
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
})
|
||||
|
||||
var itemList = []
|
||||
function refreshItemTable() {
|
||||
function refreshItemTable(urlPath) {
|
||||
$('#itemTableBody').html("<div class='ui loading segment'>Loading items</div>")
|
||||
itemList = []
|
||||
|
||||
let req = new XMLHttpRequest()
|
||||
req.open("GET", "/stale-items-list")
|
||||
req.open("GET", urlPath)
|
||||
req.send()
|
||||
req.onreadystatechange = function(){
|
||||
if (this.readyState == 4) {
|
||||
|
@ -41,8 +41,8 @@
|
|||
tbodyString += resp[i].name
|
||||
tbodyString += "</h4>"
|
||||
tbodyString += "</td>"
|
||||
tbodyString += "<td data-label='Last Updated'>"
|
||||
tbodyString += "<p class='ui right aligned large text'>" + resp[i].lastupdated + "</p>"
|
||||
tbodyString += "<td data-label='Data'>"
|
||||
tbodyString += "<p class='ui right aligned large text'>" + resp[i].data + "</p>"
|
||||
tbodyString += "</td>"
|
||||
tbodyString += "</tr>"
|
||||
}
|
||||
|
@ -66,19 +66,24 @@
|
|||
req.send()
|
||||
}
|
||||
|
||||
refreshItemTable()
|
||||
refreshItemTable("/stale-items-list")
|
||||
|
||||
</script>
|
||||
|
||||
<div class="ui segment">
|
||||
<p>This page lists the most stale items part of the metric calculation. If you have XIV Launcher and are submitting data to Universalis, you can help improve accuracy of the tool by browsing these items on the market board and then waiting for the next data refresh.</p>
|
||||
<b>Filter</b>
|
||||
<p>
|
||||
<a href="javascript:refreshItemTable('/stale-items-list')">Oldest Data (default)</a> |
|
||||
<a href="javascript:refreshItemTable('/bugged-metric-items-list')">Bugged Listing Metric</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<table id="itemTable" class="ui compact celled striped table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Name</th>
|
||||
<th>Last Updated</th>
|
||||
<th>Data</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="itemTableBody">
|
||||
|
|
Loading…
Reference in New Issue