fixed winning channel algo to use effective amount

This commit is contained in:
bill bittner 2017-10-16 21:25:29 -07:00
parent 3592d3257d
commit cb7f5ac453
6 changed files with 30 additions and 18 deletions

View file

@ -56,7 +56,8 @@ function getAssetByLongClaimId (fullClaimId, name) {
// if a result was found, return early with the result
if (dataValues) {
logger.debug('found a local file for this name and claimId');
return resolve(dataValues);
resolve(dataValues);
return;
}
logger.debug('no local file found for this name and claimId');
// 2. if no local claim, resolve and get the claim

View file

@ -102,7 +102,7 @@ function getLongChannelIdFromShortChannelId (channelName, channelId) {
function getLongChannelIdFromChannelName (channelName) {
return new Promise((resolve, reject) => {
db
.sequelize.query(`SELECT claimId, amount, height FROM Certificate WHERE name = '${channelName}' ORDER BY amount DESC, height ASC LIMIT 1;`, { type: db.sequelize.QueryTypes.SELECT })
.sequelize.query(`SELECT claimId, amount, height FROM Certificate WHERE name = '${channelName}' ORDER BY effectiveAmount DESC, height ASC LIMIT 1;`, { type: db.sequelize.QueryTypes.SELECT })
.then(result => {
switch (result.length) {
case 0:
@ -286,6 +286,7 @@ db['getAllChannelClaims'] = (channelId) => {
};
db['getLongClaimId'] = (claimName, claimId) => {
logger.debug(`getLongClaimId (${claimName}, ${claimId})`);
if (claimId && (claimId.length === 40)) {
return new Promise((resolve, reject) => resolve(claimId));
} else if (claimId && claimId.length < 40) {
@ -296,12 +297,13 @@ db['getLongClaimId'] = (claimName, claimId) => {
};
db['getLongChannelId'] = (channelName, channelId) => {
logger.debug(`getLongChannelId (${channelName}, ${channelId})`);
if (channelId && (channelId.length === 40)) { // full channel id
return new Promise((resolve, reject) => resolve(channelId));
} else if (channelId && channelId.length < 40) { // short channel id
return getLongChannelIdFromShortChannelId(channelName, channelId);
} else {
return getLongChannelIdFromChannelName(channelName);
return getLongChannelIdFromChannelName(channelName); // no channelId provided
}
};

View file

@ -413,7 +413,7 @@ table {
.nav-bar-title-section {
overflow: hidden;
border-bottom: 2px solid #eaeaea;
border-bottom: 0.5px solid #cacaca;
position: relative;
}
@ -437,7 +437,6 @@ table {
.nav-bar-subtitle {
font-size: small;
color:grey;
position: absolute;
left: 50%;
top: 50%;
@ -446,28 +445,27 @@ table {
.nav-bar-link {
font-weight: normal;
color: grey;
border-bottom: 2px solid white;
}
.nav-bar-link:hover {
color: dodgerblue;
color: black;
}
.nav-bar-link--active {
color: #1e90ff;
border-bottom: 2px solid dodgerblue;
color: black;
border-bottom: 2px solid black;
}
/* PUBLISH FORM */
.dropzone {
border: 2px dashed lightgrey;
border: 2px dashed dodgerblue;
text-align: center;
background-color: white;
}
.dropzone:hover {
border: 2px dashed #1e90ff;
background-color: gainsboro;
border: 2px dashed lightgrey;
cursor: pointer;
}

View file

@ -140,6 +140,7 @@ module.exports = (app) => {
getAsset(claimType, channelName, channelId, name, claimId)
// 2. serve or show
.then(fileInfo => {
logger.debug('file info found:', fileInfo);
if (!fileInfo) {
res.status(200).render('noClaims');
} else {
@ -177,10 +178,20 @@ module.exports = (app) => {
getChannelContents(channelName, channelId)
// 2. respond to the request
.then(result => {
const totalPages = determineTotalPages(result.claims.length);
if (!result.claims) {
res.status(200).render('noChannel');
res.status(200).render('channel', {
channelName : result.channelName,
longChannelId : result.longChannelId,
shortChannelId: result.shortChannelId,
claims : [],
previousPage : 0,
currentPage : 0,
nextPage : 0,
totalPages : 0,
totalResults : 0,
});
} else {
const totalPages = determineTotalPages(result.claims.length);
res.status(200).render('channel', {
channelName : result.channelName,
longChannelId : result.longChannelId,

View file

@ -1,4 +1,4 @@
<div class="row row--full-height">
<div class="row row--full-height row--wide">
<form>
<input class="input-file" type="file" id="siofu_input" name="siofu_input" accept="video/*,image/*" onchange="previewAndStageFile(event.target.files[0])" enctype="multipart/form-data"/>
</form>

View file

@ -2,9 +2,9 @@
<div class="input-error" id="input-error-publish-submit" hidden="true"></div>
<button id="publish-submit" class="button--primary button--large" onclick="publishStagedFile(event)">Upload</button>
</div>
<div class="row row--short align-content-center">
<p class="publish-fine-print">By clicking 'Upload', you affirm that you have the rights to publish this content to the LBRY network, and that you understand the properties of publishing it to a decentralized, user-controlled network. <a target="_blank" href="https://lbry.io/learn">[Read more]</a></p>
</div>
<div class="row row--short align-content-center">
<button class="button--cancel" onclick="cancelPublish()">Cancel</button>
</div>
<div class="row row--short align-content-center">
<p class="publish-fine-print">By clicking 'Upload', you affirm that you have the rights to publish this content to the LBRY network, and that you understand the properties of publishing it to a decentralized, user-controlled network. <a target="_blank" href="https://lbry.io/learn">[Read more]</a></p>
</div>