-
Notifications
You must be signed in to change notification settings - Fork 53
monographs: add slug field which regenerates on update #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
4fe5107 to
7e0e5fa
Compare
| if (!string.IsNullOrEmpty(monograph?.Slug)) | ||
| { | ||
| return NotFound(new | ||
| { | ||
| error = "invalid_id", | ||
| error_description = $"No such monograph found." | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still contemplating if we need to add this check. On one hand, I think it makes sense to restrict fetching monograph by id if the slug exists. On another hand, if a user's client app is a bit behind (i.e. doesn't have the slug property yet), they'll be shown the monograph link with the id which will be a 404 causing confusion
7e0e5fa to
5717b67
Compare
| return Ok(); | ||
| } | ||
|
|
||
| [HttpGet("{id}/publish-url")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can combine analytics and publish-url endpoints into one?
| var userMonographs = await Repositories.Monographs.Collection.Find(filter).Project((m) => new MonographMetadata | ||
| var userMonographs = await Repositories.Monographs.Collection.Find(filter).ToListAsync(); | ||
| var userMonographMetadatas = userMonographs.Select((m) => new MonographMetadata | ||
| { | ||
| DatePublished = m.DatePublished, | ||
| Deleted = m.Deleted, | ||
| Password = m.Password, | ||
| SelfDestruct = m.SelfDestruct, | ||
| Title = m.Title, | ||
| PublishUrl = m.ConstructPublishUrl(), | ||
| ItemId = m.ItemId ?? m.Id.ToString(), | ||
| ViewCount = m.ViewCount | ||
| }).ToListAsync(); | ||
| }).ToList(); | ||
|
|
||
| if (userMonographs.Count > 0 && !await Clients.Caller.SendMonographs(userMonographs).WaitAsync(TimeSpan.FromMinutes(10))) | ||
| if (userMonographMetadatas.Count > 0 && !await Clients.Caller.SendMonographs(userMonographMetadatas).WaitAsync(TimeSpan.FromMinutes(10))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unable to use m.ConstructPublishUrl method inside MongoDB's Project. It would throw expression not supported exception
No description provided.