Style fixes
This commit is contained in:
parent
145b3ea766
commit
f984dec95a
@ -63,7 +63,7 @@ class Contributor extends Record {
|
|||||||
|
|
||||||
updateProfile (contributorId, updateAttr, callOptions = {}) {
|
updateProfile (contributorId, updateAttr, callOptions = {}) {
|
||||||
return this.getById(contributorId).then(async (contributor) => {
|
return this.getById(contributorId).then(async (contributor) => {
|
||||||
let updatedContributorAttr = Object.assign(contributor, updateAttr)
|
let updatedContributorAttr = Object.assign(contributor, updateAttr);
|
||||||
let updatedContributor = new ContributorSerializer(updatedContributorAttr);
|
let updatedContributor = new ContributorSerializer(updatedContributorAttr);
|
||||||
|
|
||||||
try { await updatedContributor.validate(); }
|
try { await updatedContributor.validate(); }
|
||||||
|
@ -2,7 +2,7 @@ const Base = require('./base');
|
|||||||
const paged = require('../utils/pagination');
|
const paged = require('../utils/pagination');
|
||||||
|
|
||||||
class Record extends Base {
|
class Record extends Base {
|
||||||
all(options = {}) {
|
all (options = {}) {
|
||||||
return this.count
|
return this.count
|
||||||
.then((count) => {
|
.then((count) => {
|
||||||
let records = paged(count, options).map((id) => this.getById(id));
|
let records = paged(count, options).map((id) => this.getById(id));
|
||||||
@ -11,4 +11,4 @@ class Record extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Record
|
module.exports = Record;
|
||||||
|
@ -31,39 +31,39 @@ class Contributor {
|
|||||||
} = this;
|
} = this;
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
"@context": "https://schema.kosmos.org",
|
'@context': 'https://schema.kosmos.org',
|
||||||
"@type": "Contributor",
|
'@type': 'Contributor',
|
||||||
kind,
|
kind,
|
||||||
name,
|
name,
|
||||||
"accounts": [],
|
'accounts': [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
data["url"] = url;
|
data['url'] = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (github_uid) {
|
if (github_uid) {
|
||||||
data.accounts.push({
|
data.accounts.push({
|
||||||
"site": "github.com",
|
'site': 'github.com',
|
||||||
"uid": github_uid,
|
'uid': github_uid,
|
||||||
"username": github_username,
|
'username': github_username,
|
||||||
"url": `https://github.com/${github_username}`,
|
'url': `https://github.com/${github_username}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gitea_username) {
|
if (gitea_username) {
|
||||||
data.accounts.push({
|
data.accounts.push({
|
||||||
"site": "gitea.kosmos.org",
|
'site': 'gitea.kosmos.org',
|
||||||
"username": gitea_username,
|
'username': gitea_username,
|
||||||
"url": `https://gitea.kosmos.org/${gitea_username}`
|
'url': `https://gitea.kosmos.org/${gitea_username}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wiki_username) {
|
if (wiki_username) {
|
||||||
data.accounts.push({
|
data.accounts.push({
|
||||||
"site": "wiki.kosmos.org",
|
'site': 'wiki.kosmos.org',
|
||||||
"username": wiki_username,
|
'username': wiki_username,
|
||||||
"url": `https://wiki.kosmos.org/User:${wiki_username}`,
|
'url': `https://wiki.kosmos.org/User:${wiki_username}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const ethersUtils = require('ethers').utils;
|
const ethersUtils = require('ethers').utils;
|
||||||
|
|
||||||
module.exports = function (value, options = {}) {
|
module.exports = function(value, options = {}) {
|
||||||
let etherValue = ethersUtils.formatEther(value);
|
let etherValue = ethersUtils.formatEther(value);
|
||||||
if (options.asFloat) {
|
if (options.asFloat) {
|
||||||
return parseFloat(etherValue);
|
return parseFloat(etherValue);
|
||||||
} else {
|
} else {
|
||||||
return parseInt(etherValue);
|
return parseInt(etherValue);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function pageNumber(number, size, recordCount) {
|
function pageNumber (number, size, recordCount) {
|
||||||
let numberOfPages = Math.ceil(recordCount / size);
|
let numberOfPages = Math.ceil(recordCount / size);
|
||||||
|
|
||||||
number = parseInt(number) || 1;
|
number = parseInt(number) || 1;
|
||||||
@ -10,7 +10,7 @@ function pageNumber(number, size, recordCount) {
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildIds(order, number, size, recordCount) {
|
function buildIds (order, number, size, recordCount) {
|
||||||
let offset = size * (number - 1);
|
let offset = size * (number - 1);
|
||||||
|
|
||||||
let start;
|
let start;
|
||||||
@ -34,7 +34,7 @@ function buildIds(order, number, size, recordCount) {
|
|||||||
return Array.from({ length: size }, mapFunction);
|
return Array.from({ length: size }, mapFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function paged(recordCount, options = {}) {
|
module.exports = function paged (recordCount, options = {}) {
|
||||||
let { order, page } = options;
|
let { order, page } = options;
|
||||||
order = order || 'desc';
|
order = order || 'desc';
|
||||||
page = page || {};
|
page = page || {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user