Conversation
|
|
||
| public Optional<CommitJson> findById(String docId) { | ||
| return this.findById(getIndex(), docId); | ||
| public void index(BaseJson json, String commitId) { |
There was a problem hiding this comment.
i don't think this is needed - the caller should just give the right commitJson to index and not have to know about commitId overrides
|
|
||
| public void indexAll(Collection<? extends BaseJson> jsons) { | ||
| this.indexAll(getIndex(), jsons); | ||
| this.indexAll(getIndex(), associateCommits(jsons)); |
There was a problem hiding this comment.
this should index commits 'as is' (see below for more), it shouldn't assume that indexing a collection of commit json means they're all related
also, the signature of this and index should probably change to CommitJson instead of BaseJson
| } | ||
|
|
||
| public void index(BaseJson json) { | ||
| if (json.get(CommitJson.COMMITID).toString().isEmpty()) { |
There was a problem hiding this comment.
I think what should happen here (and in indexAll) is the breaking up of a single commit json into several if its arrays exceeds some threshold - so the caller can give a huge object, but because of the elasticsearch limits, only the elastic impl knows to break it up (similar to how the get knows to munge commit objects together and can return a huge object to the caller, the caller doesn't need to know about munging)
At the same time, if the caller already broke up the commits, this would still work as expected
There was a problem hiding this comment.
Done, but it might be done in a different way
| } | ||
|
|
||
| public void deleteById(String commitId) { | ||
| this.deleteById(getIndex(), commitId); |
There was a problem hiding this comment.
this should delete all docs that have commitId, right now it treats commitId as the docId
| public boolean existsById(String docId) { | ||
| return this.existsById(getIndex(), docId); | ||
| public boolean existsById(String commitId) { | ||
| return this.existsById(getIndex(), commitId); |
|
|
||
| String commitId = params.get("commitId"); | ||
| if (commitId != null && !commitId.isEmpty()) { | ||
| info.getCommitJson().setCommitId(commitId); |
There was a problem hiding this comment.
this should happen during the createCommit in the previous call, otherwise the elements getting updated will have the wrong commitId
|
|
||
| public void initCommitJson(CommitJson cmjs, Instant now) { | ||
| cmjs.setId(UUID.randomUUID().toString()); | ||
| cmjs.setCommitId(UUID.randomUUID().toString()); |
There was a problem hiding this comment.
this should check if commitId is not set first, if it's not set, it should just be same as the id so it's still consistent with any existing paradigm
| broken.add(currentCommitCopy); | ||
|
|
||
| } | ||
| this.indexAll(broken); |
There was a problem hiding this comment.
Just fyi, this adds a property called "action" into the commit objects. We could remove it if it's a problem.
| commit.setComment(cmjs.getComment()); | ||
|
|
||
| this.commitRepository.save(commit); | ||
| Optional<Commit> existing = this.commitRepository.findByCommitId(cmjs.getCommitId()); |
| cmjs.setProjectId(projectId); | ||
|
|
||
| if (commitId != null && !commitId.isEmpty()) { | ||
| cmjs.setId(commitId); |
There was a problem hiding this comment.
there's somewhere else (initCommit)? that needs to be updated to check for existing id and generate docId
|
|
||
| n.setDocId(e.getDocId()); | ||
| n.setLastCommit(cmjs.getId()); | ||
| n.setLastCommit(cmjs.getCommitId()); |
| case "deleted": | ||
| currentCommitCopy.getDeleted().add(action); | ||
| break; | ||
| } |
| private List<CommitJson> getDocs(String commitId) { | ||
| try { | ||
| QueryBuilder commitQuery = QueryBuilders.boolQuery() | ||
| .should(QueryBuilders.termQuery(CommitJson.ID, commitId)) |
There was a problem hiding this comment.
this is better as a filter instead of should
| public class CommitElasticDAOImpl extends BaseElasticDAOImpl<CommitJson> implements CommitIndexDAO { | ||
|
|
||
| @Value("${elasticsearch.limit.index}") | ||
| int indexLimit; |
There was a problem hiding this comment.
should we be using the same limit for indexing vs splitting up commit? the commit can be a lot bigger than whatever we set the index limit to (currently used in bulk processor) (this is already injected in the BaseDao as bulkLimit)
| partial.setId(""); | ||
| } | ||
|
|
||
| if (partial.getAdded().isEmpty() && raw.getAdded() != null) { |
There was a problem hiding this comment.
I don't think the first check should be here? this would only add addition data if partial is empty but we want to add them regardless
| if (partial.getId() == null) { | ||
| partial.setId(""); | ||
| } | ||
| if (partial.getId() == null) { |
| if (partial.getComment().isEmpty() && raw.getComment() != null) { | ||
| partial.setComment(raw.getComment()); | ||
| } | ||
| if (partial.getId().isEmpty() && raw.getCommitId() != null) { |
| throw new BadRequestException(response.addMessage("Empty")); | ||
| } | ||
|
|
||
| @PostMapping(value = "/stream", consumes = MediaType.APPLICATION_JSON_VALUE) |
There was a problem hiding this comment.
can comment this function out for now so it doesn't show up in generated swagger
| } | ||
| return commits; | ||
| ArrayList<CommitJson> result = new ArrayList<>(); | ||
| for (String key : rawCommits.keySet()) { |
There was a problem hiding this comment.
does using keySet retain ordering?
also because of the query, the commit objects returned wouldn't be the entire object if it was split - we used to just return the commit id and some metadata for element history, maybe we can just do that again
| }, | ||
| "response": [] | ||
| }, | ||
| { |
| "_projectId": { | ||
| "type": "keyword" | ||
| }, | ||
| "_docId": { |
| public static final String SOURCE = "source"; | ||
|
|
||
| public static CommitJson copy(CommitJson original) { | ||
| CommitJson copy = new CommitJson(); |
No description provided.