From 20a20cc8db2b83a59e5faa5bbe9b4d1df179d3ed Mon Sep 17 00:00:00 2001 From: Andrei Kurilov <18027129+akurilov@users.noreply.github.com> Date: Sun, 11 Aug 2024 08:42:30 +0300 Subject: [PATCH] feat: utilize the discover flag in interest events --- .github/workflows/staging.yaml | 82 +++++++++++++++++----------------- main.go | 10 +++-- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index eee6002..f875a56 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -67,47 +67,47 @@ jobs: --region ${{ secrets.GKE_CLUSTER_REGION }} \ --project ${{ secrets.GKE_PROJECT_ID }} -# - name: Helm Upgrade 1 -# run: | -# helm upgrade --install ${COMPONENT} helm/package/${COMPONENT}-0.0.0.tgz \ -# --values helm/int-mastodon/values-mastodon-social-0.yaml \ -# --set-string podAnnotations.commit=$(git rev-parse --short HEAD) -# -# - name: Helm Upgrade 2 -# run: | -# helm upgrade --install ${COMPONENT}-infosec-exchange helm/package/${COMPONENT}-0.0.0.tgz \ -# --values helm/int-mastodon/values-infosec-exchange-0.yaml \ -# --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ -# -# - name: Helm Upgrade 3 -# run: | -# helm upgrade --install ${COMPONENT}-mstdn-social helm/package/${COMPONENT}-0.0.0.tgz \ -# --values helm/int-mastodon/values-mstdn-social-0.yaml \ -# --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ -# -# - name: Helm Upgrade 4 -# run: | -# helm upgrade --install ${COMPONENT}-botsin-space helm/package/${COMPONENT}-0.0.0.tgz \ -# --values helm/int-mastodon/values-botsin-space-0.yaml \ -# --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ -# -# - name: Helm Upgrade 5 -# run: | -# helm upgrade --install ${COMPONENT}-flipboard-social helm/package/${COMPONENT}-0.0.0.tgz \ -# --values helm/int-mastodon/values-flipboard-social-0.yaml \ -# --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ -# -# - name: Helm Upgrade 6 -# run: | -# helm upgrade --install ${COMPONENT}-mastodon-cloud helm/package/${COMPONENT}-0.0.0.tgz \ -# --values helm/int-mastodon/values-mastodon-cloud-0.yaml \ -# --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ -# -# - name: Helm Upgrade 7 -# run: | -# helm upgrade --install ${COMPONENT}-techhub-social helm/package/${COMPONENT}-0.0.0.tgz \ -# --values helm/int-mastodon/values-techhub-social-0.yaml \ -# --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ + - name: Helm Upgrade 1 + run: | + helm upgrade --install ${COMPONENT} helm/package/${COMPONENT}-0.0.0.tgz \ + --values helm/int-mastodon/values-mastodon-social-0.yaml \ + --set-string podAnnotations.commit=$(git rev-parse --short HEAD) + + - name: Helm Upgrade 2 + run: | + helm upgrade --install ${COMPONENT}-infosec-exchange helm/package/${COMPONENT}-0.0.0.tgz \ + --values helm/int-mastodon/values-infosec-exchange-0.yaml \ + --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ + + - name: Helm Upgrade 3 + run: | + helm upgrade --install ${COMPONENT}-mstdn-social helm/package/${COMPONENT}-0.0.0.tgz \ + --values helm/int-mastodon/values-mstdn-social-0.yaml \ + --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ + + - name: Helm Upgrade 4 + run: | + helm upgrade --install ${COMPONENT}-botsin-space helm/package/${COMPONENT}-0.0.0.tgz \ + --values helm/int-mastodon/values-botsin-space-0.yaml \ + --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ + + - name: Helm Upgrade 5 + run: | + helm upgrade --install ${COMPONENT}-flipboard-social helm/package/${COMPONENT}-0.0.0.tgz \ + --values helm/int-mastodon/values-flipboard-social-0.yaml \ + --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ + + - name: Helm Upgrade 6 + run: | + helm upgrade --install ${COMPONENT}-mastodon-cloud helm/package/${COMPONENT}-0.0.0.tgz \ + --values helm/int-mastodon/values-mastodon-cloud-0.yaml \ + --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ + + - name: Helm Upgrade 7 + run: | + helm upgrade --install ${COMPONENT}-techhub-social helm/package/${COMPONENT}-0.0.0.tgz \ + --values helm/int-mastodon/values-techhub-social-0.yaml \ + --set-string podAnnotations.commit=$(git rev-parse --short HEAD) \ - name: Helm Upgrade 8 run: | diff --git a/main.go b/main.go index e0324d6..44dcf99 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ import ( const ceKeyGroupId = "awakarigroupid" const ceKeyQueriesCompl = "queriescompl" const ceKeyPublic = "public" +const ceKeyDiscover = "discover" func main() { // @@ -179,14 +180,15 @@ func consumeEvents( log.Debug(fmt.Sprintf("interest %s event: public: %t/%t", interestId, publicAttrPresent, publicAttr.GetCeBoolean())) } + var discover bool + if attrDiscover, attrDiscoverExists := evt.Attributes[ceKeyDiscover]; attrDiscoverExists { + discover = attrDiscover.GetCeBoolean() + } var queries []string if queriesComplAttr, queriesComplPresent := evt.Attributes[ceKeyQueriesCompl]; queriesComplPresent { queries = strings.Split(queriesComplAttr.GetCeString(), "\n") } - switch len(queries) { - case 0: - log.Debug(fmt.Sprintf("interest %s event: no queries, skipping the sources discovery", interestId)) - default: + if discover && len(queries) > 0 { for _, q := range queries { _, _ = svc.SearchAndAdd(ctx, interestId, groupId, q, cfg.Api.Mastodon.Search.Limit, model.SearchTypeStatuses) }