Skip to content

Search for related a/b/i not using cursors#158

Merged
tarekio merged 8 commits intomainfrom
BYNT-1433-Search-for-Related-Actors-Bulletins-Incidents-Limited-to-30-Results
Aug 22, 2025
Merged

Search for related a/b/i not using cursors#158
tarekio merged 8 commits intomainfrom
BYNT-1433-Search-for-Related-Actors-Bulletins-Incidents-Limited-to-30-Results

Conversation

@apodacaduron
Copy link
Contributor

@apodacaduron apodacaduron commented Aug 13, 2025

Jira Issue

  1. BYNT-1433

Description

Update relate dialog since it was not using the new cursor based requests for a/b/i, also updated export card since it had the same issue

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • New strings prepared for translations

API Changes (if applicable)

  • Permissions checked
  • Endpoint tests added

Additional Notes

[Any other relevant information]

@apodacaduron apodacaduron requested a review from tarekio August 13, 2025 23:09
@apodacaduron apodacaduron self-assigned this Aug 13, 2025
Copy link
Contributor

@tarekio tarekio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go. @level09 please review code changes.

@tarekio tarekio requested a review from level09 August 18, 2025 23:08
Copy link
Collaborator

@level09 level09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go.

Would have been nice if we had abstracted the exact same functionality into a mixin like this

relatedSearchMixin = {
    props: {
      exids: { type: Array, default: () => [] }
    },

    data() {
      return {
        q: {},
        loading: true,
        results: [],
        visible: false,
        perPage: 10,
        hasMore: false,
        nextCursor: null,
      };
    },

    methods: {
      async performSearch() {
        this.loading = true;

        const requestData = {
          q: [this.q],
          per_page: this.perPage,
          cursor: this.nextCursor,
        };

        try {
          const response = await
  axios.post(`/admin/api/${this.entityType}s/?mode=2`, requestData);
          this.loading = false;

          const excludeIds = this.exids || [];
          const filteredItems = response.data.items.filter((x) =>
  !excludeIds.includes(x.id));
          this.results = [...this.results, ...filteredItems];

          this.hasMore = response.data.meta.hasMore;
          this.nextCursor = response.data.nextCursor || null;
        } catch (err) {
          this.loading = false;
          console.log(err.response?.data);
        }
      },

      reSearch() {
        this.results = [];
        this.nextCursor = null;
        this.performSearch();
      },

      search() {
        this.performSearch();
      },

      reset() {
        this.q = {};
        this.results = [];
        this.nextCursor = null;
        this.hasMore = false;
        this.visible = false;
      }
    }
  };

this way we centralize code and can update functions globally in one place if we need to.

@apodacaduron
Copy link
Contributor Author

@level09 updated, i've centralized the repeated logic in a new mixin

@apodacaduron apodacaduron requested a review from level09 August 19, 2025 22:27
@tarekio tarekio merged commit 6349898 into main Aug 22, 2025
7 checks passed
@tarekio tarekio deleted the BYNT-1433-Search-for-Related-Actors-Bulletins-Incidents-Limited-to-30-Results branch August 22, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants