Display document views (#849)
* Display who has viewed a document in the header * Add overflow, display of WHEN last viewed Cleanup old document attributes Add firstViewedAt, lastViewedAt to API response * Cleanup * Added: API documentation for views endpoints * Include views for deleted users
This commit is contained in:
@ -32,8 +32,6 @@ async function present(ctx: Object, document: Document, options: ?Options) {
|
||||
updatedAt: document.updatedAt,
|
||||
updatedBy: undefined,
|
||||
publishedAt: document.publishedAt,
|
||||
firstViewedAt: undefined,
|
||||
lastViewedAt: undefined,
|
||||
team: document.teamId,
|
||||
collaborators: [],
|
||||
starred: !!(document.starred && document.starred.length),
|
||||
@ -41,7 +39,6 @@ async function present(ctx: Object, document: Document, options: ?Options) {
|
||||
pinned: undefined,
|
||||
collectionId: undefined,
|
||||
collection: undefined,
|
||||
views: undefined,
|
||||
};
|
||||
|
||||
if (!options.isPublic) {
|
||||
@ -54,12 +51,6 @@ async function present(ctx: Object, document: Document, options: ?Options) {
|
||||
data.collection = await presentCollection(ctx, document.collection);
|
||||
}
|
||||
|
||||
if (document.views && document.views.length === 1) {
|
||||
data.views = document.views[0].count;
|
||||
data.firstViewedAt = document.views[0].createdAt;
|
||||
data.lastViewedAt = document.views[0].updatedAt;
|
||||
}
|
||||
|
||||
// This could be further optimized by using ctx.cache
|
||||
data.collaborators = await User.findAll({
|
||||
where: {
|
||||
|
Reference in New Issue
Block a user