fixed winning channel algo to use effective amount
This commit is contained in:
parent
3592d3257d
commit
cb7f5ac453
6 changed files with 30 additions and 18 deletions
|
@ -56,7 +56,8 @@ function getAssetByLongClaimId (fullClaimId, name) {
|
||||||
// if a result was found, return early with the result
|
// if a result was found, return early with the result
|
||||||
if (dataValues) {
|
if (dataValues) {
|
||||||
logger.debug('found a local file for this name and claimId');
|
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');
|
logger.debug('no local file found for this name and claimId');
|
||||||
// 2. if no local claim, resolve and get the claim
|
// 2. if no local claim, resolve and get the claim
|
||||||
|
|
|
@ -102,7 +102,7 @@ function getLongChannelIdFromShortChannelId (channelName, channelId) {
|
||||||
function getLongChannelIdFromChannelName (channelName) {
|
function getLongChannelIdFromChannelName (channelName) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
db
|
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 => {
|
.then(result => {
|
||||||
switch (result.length) {
|
switch (result.length) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -286,6 +286,7 @@ db['getAllChannelClaims'] = (channelId) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
db['getLongClaimId'] = (claimName, claimId) => {
|
db['getLongClaimId'] = (claimName, claimId) => {
|
||||||
|
logger.debug(`getLongClaimId (${claimName}, ${claimId})`);
|
||||||
if (claimId && (claimId.length === 40)) {
|
if (claimId && (claimId.length === 40)) {
|
||||||
return new Promise((resolve, reject) => resolve(claimId));
|
return new Promise((resolve, reject) => resolve(claimId));
|
||||||
} else if (claimId && claimId.length < 40) {
|
} else if (claimId && claimId.length < 40) {
|
||||||
|
@ -296,12 +297,13 @@ db['getLongClaimId'] = (claimName, claimId) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
db['getLongChannelId'] = (channelName, channelId) => {
|
db['getLongChannelId'] = (channelName, channelId) => {
|
||||||
|
logger.debug(`getLongChannelId (${channelName}, ${channelId})`);
|
||||||
if (channelId && (channelId.length === 40)) { // full channel id
|
if (channelId && (channelId.length === 40)) { // full channel id
|
||||||
return new Promise((resolve, reject) => resolve(channelId));
|
return new Promise((resolve, reject) => resolve(channelId));
|
||||||
} else if (channelId && channelId.length < 40) { // short channel id
|
} else if (channelId && channelId.length < 40) { // short channel id
|
||||||
return getLongChannelIdFromShortChannelId(channelName, channelId);
|
return getLongChannelIdFromShortChannelId(channelName, channelId);
|
||||||
} else {
|
} else {
|
||||||
return getLongChannelIdFromChannelName(channelName);
|
return getLongChannelIdFromChannelName(channelName); // no channelId provided
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,7 @@ table {
|
||||||
|
|
||||||
.nav-bar-title-section {
|
.nav-bar-title-section {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-bottom: 2px solid #eaeaea;
|
border-bottom: 0.5px solid #cacaca;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,6 @@ table {
|
||||||
|
|
||||||
.nav-bar-subtitle {
|
.nav-bar-subtitle {
|
||||||
font-size: small;
|
font-size: small;
|
||||||
color:grey;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
@ -446,28 +445,27 @@ table {
|
||||||
|
|
||||||
.nav-bar-link {
|
.nav-bar-link {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
|
color: grey;
|
||||||
border-bottom: 2px solid white;
|
border-bottom: 2px solid white;
|
||||||
}
|
}
|
||||||
.nav-bar-link:hover {
|
.nav-bar-link:hover {
|
||||||
color: dodgerblue;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-bar-link--active {
|
.nav-bar-link--active {
|
||||||
color: #1e90ff;
|
color: black;
|
||||||
border-bottom: 2px solid dodgerblue;
|
border-bottom: 2px solid black;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PUBLISH FORM */
|
/* PUBLISH FORM */
|
||||||
|
|
||||||
.dropzone {
|
.dropzone {
|
||||||
border: 2px dashed lightgrey;
|
border: 2px dashed dodgerblue;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropzone:hover {
|
.dropzone:hover {
|
||||||
border: 2px dashed #1e90ff;
|
border: 2px dashed lightgrey;
|
||||||
background-color: gainsboro;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,7 @@ module.exports = (app) => {
|
||||||
getAsset(claimType, channelName, channelId, name, claimId)
|
getAsset(claimType, channelName, channelId, name, claimId)
|
||||||
// 2. serve or show
|
// 2. serve or show
|
||||||
.then(fileInfo => {
|
.then(fileInfo => {
|
||||||
|
logger.debug('file info found:', fileInfo);
|
||||||
if (!fileInfo) {
|
if (!fileInfo) {
|
||||||
res.status(200).render('noClaims');
|
res.status(200).render('noClaims');
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,10 +178,20 @@ module.exports = (app) => {
|
||||||
getChannelContents(channelName, channelId)
|
getChannelContents(channelName, channelId)
|
||||||
// 2. respond to the request
|
// 2. respond to the request
|
||||||
.then(result => {
|
.then(result => {
|
||||||
const totalPages = determineTotalPages(result.claims.length);
|
|
||||||
if (!result.claims) {
|
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 {
|
} else {
|
||||||
|
const totalPages = determineTotalPages(result.claims.length);
|
||||||
res.status(200).render('channel', {
|
res.status(200).render('channel', {
|
||||||
channelName : result.channelName,
|
channelName : result.channelName,
|
||||||
longChannelId : result.longChannelId,
|
longChannelId : result.longChannelId,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="row row--full-height">
|
<div class="row row--full-height row--wide">
|
||||||
<form>
|
<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"/>
|
<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>
|
</form>
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
<div class="input-error" id="input-error-publish-submit" hidden="true"></div>
|
<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>
|
<button id="publish-submit" class="button--primary button--large" onclick="publishStagedFile(event)">Upload</button>
|
||||||
</div>
|
</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">
|
<div class="row row--short align-content-center">
|
||||||
<button class="button--cancel" onclick="cancelPublish()">Cancel</button>
|
<button class="button--cancel" onclick="cancelPublish()">Cancel</button>
|
||||||
</div>
|
</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>
|
||||||
|
|
Loading…
Reference in a new issue