Skip to content

Commit

Permalink
- App: Pagination Code Smells, TR with FQ was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alegauss committed Feb 25, 2024
1 parent 7f6a3e7 commit 2667bbd
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
package com.viglet.turing.api.sn.bean;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;

@RequiredArgsConstructor
@Accessors(chain = true)
@Getter
@Setter
public class TurSNSiteFilterQueryBean {
Expand Down
353 changes: 169 additions & 184 deletions turing-app/src/main/java/com/viglet/turing/sn/TurSNSearchProcess.java

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions turing-app/src/main/java/com/viglet/turing/solr/TurSolr.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private void prepareGroup(TurSEParameters turSEParameters, SolrQuery query) {

}

private boolean hasGroup(TurSEParameters turSEParameters) {
public boolean hasGroup(TurSEParameters turSEParameters) {
return turSEParameters.getGroup() != null && !turSEParameters.getGroup().trim().isEmpty();
}

Expand Down Expand Up @@ -671,7 +671,7 @@ private void prepareQueryTargetingRules(TurSNSitePostParamsBean turSNSitePostPar
condition.add(key);
rules.add(turSNTargetingRules.run(TurSNTargetingRuleMethod.AND, key, value));
});
query.setFilterQueries(String.format("%s OR (*:* NOT (%s))",
query.addFilterQuery(String.format("%s OR (*:* NOT (%s))",
String.join(" OR ", rules),
String.join(" OR ", condition)));
}
Expand All @@ -684,15 +684,15 @@ private void prepareQueryFilterQuery(TurSEParameters turSEParameters, SolrQuery
List<String> filterQueriesModified = turSEParameters.getFilterQueries().stream()
.map(q -> queryWithoutExpression(q) ? addDoubleQuotesToValue(q) : q
).toList();
query.setFilterQueries(
query.addFilterQuery(
String.valueOf(String.format("%s(%s)", facetTypeCondition,
String.join(" OR ", filterQueriesModified))));
} else {
List<String> filterQueriesModified = turSEParameters.getFilterQueries().stream()
.map(q -> facetTypeCondition.concat(queryWithoutExpression(q) ? addDoubleQuotesToValue(q) : q)
).toList();
String[] filterQueryArr = new String[filterQueriesModified.size()];
query.setFilterQueries(filterQueriesModified.toArray(filterQueryArr));
query.addFilterQuery(filterQueriesModified.toArray(filterQueryArr));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.Locale;

Expand All @@ -28,7 +30,8 @@
*
* @since 0.3.5
*/

@RequiredArgsConstructor
@Accessors(chain = true)
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@

package com.viglet.turing.commons.sn.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;


@RequiredArgsConstructor
@Accessors(chain = true)
@Getter
@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TurSNSiteSearchBean {
private List<TurSNSiteSearchPaginationBean> pagination;
private TurSNSiteSearchQueryContextBean queryContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@
package com.viglet.turing.commons.sn.bean;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
* List of spotlight documents of Turing AI Semantic Navigation response.
*
* @author Alexandre Oliveira
* @since 0.3.5
*/

@RequiredArgsConstructor
@Accessors(chain = true)
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class TurSNSiteSpotlightDocumentBean {

Expand All @@ -43,59 +50,4 @@ public class TurSNSiteSpotlightDocumentBean {

private String link;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public int getPosition() {
return position;
}

public void setPosition(int position) {
this.position = position;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getReferenceId() {
return referenceId;
}

public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public String getLink() {
return link;
}

public void setLink(String link) {
this.link = link;
}
}

0 comments on commit 2667bbd

Please sign in to comment.