added GA timing event for claim availability search
This commit is contained in:
parent
2d10bebd69
commit
97dab8fd38
2 changed files with 9 additions and 5 deletions
|
@ -88,7 +88,11 @@ module.exports = {
|
||||||
},
|
},
|
||||||
claimNameIsAvailable (name) {
|
claimNameIsAvailable (name) {
|
||||||
// find any records where the name is used
|
// find any records where the name is used
|
||||||
return db.File.findAll({ where: { name } })
|
return db.Claim
|
||||||
|
.findAll({
|
||||||
|
attributes: ['address'],
|
||||||
|
where : { name },
|
||||||
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.length >= 1) {
|
if (result.length >= 1) {
|
||||||
const claimAddress = config.wallet.lbryClaimAddress;
|
const claimAddress = config.wallet.lbryClaimAddress;
|
||||||
|
|
|
@ -107,10 +107,12 @@ module.exports = (app) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// route to check whether this site published to a claim
|
// route to check whether this site published to a claim
|
||||||
app.get('/api/claim/availability/:name', ({ ip, originalUrl, params }, res) => {
|
app.get('/api/claim/availability/:name', ({ ip, originalUrl, params: { name } }, res) => {
|
||||||
claimNameIsAvailable(params.name)
|
const gaStartTime = Date.now();
|
||||||
|
claimNameIsAvailable(name)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
res.status(200).json(result);
|
res.status(200).json(result);
|
||||||
|
sendGATimingEvent('end-to-end', 'claim name availability', name, gaStartTime, Date.now());
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
errorHandlers.handleErrorResponse(originalUrl, ip, error, res);
|
errorHandlers.handleErrorResponse(originalUrl, ip, error, res);
|
||||||
|
@ -128,8 +130,6 @@ module.exports = (app) => {
|
||||||
});
|
});
|
||||||
// route to run a publish request on the daemon
|
// route to run a publish request on the daemon
|
||||||
app.post('/api/claim/publish', multipartMiddleware, ({ body, files, headers, ip, originalUrl, user }, res) => {
|
app.post('/api/claim/publish', multipartMiddleware, ({ body, files, headers, ip, originalUrl, user }, res) => {
|
||||||
logger.debug('api/claim/publish req.body:', body);
|
|
||||||
logger.debug('api/claim/publish req.files:', files);
|
|
||||||
// define variables
|
// define variables
|
||||||
let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title;
|
let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title;
|
||||||
// record the start time of the request
|
// record the start time of the request
|
||||||
|
|
Loading…
Reference in a new issue