From 0dbab04835cfa4917248593e15c1c31be134980b Mon Sep 17 00:00:00 2001 From: h0lybyte <5599058+h0lybyte@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:50:56 -0400 Subject: [PATCH 1/3] feat: adding the search ability for the data from idb. --- src/core/mod.rs | 1 + src/core/uiux/mod.rs | 1 + src/core/uiux/search.rs | 41 +++++++++++++++++++++++++++++++++++++++++ src/db/mod.rs | 1 - src/main.rs | 1 - 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/core/mod.rs create mode 100644 src/core/uiux/mod.rs create mode 100644 src/core/uiux/search.rs diff --git a/src/core/mod.rs b/src/core/mod.rs new file mode 100644 index 0000000..037eb02 --- /dev/null +++ b/src/core/mod.rs @@ -0,0 +1 @@ +pub mod uiux; \ No newline at end of file diff --git a/src/core/uiux/mod.rs b/src/core/uiux/mod.rs new file mode 100644 index 0000000..e092c24 --- /dev/null +++ b/src/core/uiux/mod.rs @@ -0,0 +1 @@ +pub mod search; \ No newline at end of file diff --git a/src/core/uiux/search.rs b/src/core/uiux/search.rs new file mode 100644 index 0000000..b8e494d --- /dev/null +++ b/src/core/uiux/search.rs @@ -0,0 +1,41 @@ +use crate::db::github::Repository; +use crate::db::idb; +use egui::{Context, Id}; + +pub struct SearchWidget { + pub query: String, + pub results: Vec, + pub loading: bool, +} + +impl SearchWidget { + pub fn new() -> Self { + Self { + query: String::new(), + results: Vec::new(), + loading: false, + } + } + + pub fn search(&mut self, language: &str, ctx: &Context) { + let query = self.query.clone(); + let language = language.to_string(); + let ctx = ctx.clone(); + self.loading = true; + wasm_bindgen_futures::spawn_local(async move { + let result = match idb::open_waffle_db().await { + Ok(db_conn) => idb::filter_repos_in_idb::(&db_conn, &language, &query).await.unwrap_or_default(), + Err(_) => vec![], + }; + ctx.data_mut(|d| d.insert_temp(Id::new("waffle_search_results"), result)); + ctx.request_repaint(); + }); + } + + pub fn update_results_from_ctx(&mut self, ctx: &Context) { + if let Some(results) = ctx.data(|d| d.get_temp::>(Id::new("waffle_search_results"))) { + self.results = results.clone(); + self.loading = false; + } + } +} diff --git a/src/db/mod.rs b/src/db/mod.rs index 67e40f4..12dd5f4 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -1,3 +1,2 @@ pub mod github; -pub use github::*; pub mod idb; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9b7c2ad..59f7d3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,6 @@ fn main() { use eframe::wasm_bindgen::JsCast as _; - // Redirect `log` message to `console.log` and friends: eframe::WebLogger::init(log::LevelFilter::Debug).ok(); let web_options = eframe::WebOptions::default(); From a22eab813b0580999a96dec8df23fdc8a231fd3f Mon Sep 17 00:00:00 2001 From: h0lybyte <5599058+h0lybyte@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:52:19 -0400 Subject: [PATCH 2/3] ci: fixing the pipeline. --- .github/workflows/pipeline.yml | 2 +- .github/workflows/rust.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f7917dd..066f33f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,7 +1,7 @@ name: Auto PR from dev* to main for h0lybyte on: - pull_request: + push: branches: - 'dev*' diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 12610bf..d46e169 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -on: [push, pull_request, workflow_dispatch] +on: [pull_request, workflow_dispatch] name: CI From 9305fcf98982a3548059640ff6e1f8b4c1ff851e Mon Sep 17 00:00:00 2001 From: h0lybyte <5599058+h0lybyte@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:55:36 -0400 Subject: [PATCH 3/3] ci: cleaned up the pipeline. --- .github/workflows/pipeline.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 066f33f..6654c24 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -4,6 +4,7 @@ on: push: branches: - 'dev*' + workflow_dispatch: concurrency: group: pr-auto-${{ github.head_ref }} @@ -13,13 +14,8 @@ jobs: auto-pr-to-main: runs-on: ubuntu-latest if: | - github.actor == 'h0lybyte' + github.repository == 'KBVE/waffle' && github.actor == 'h0lybyte' steps: - - name: Check if user is a member of KBVE - id: org-check - run: | - curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/orgs/KBVE/members/h0lybyte | grep 'login' || exit 1 - name: Checkout code uses: actions/checkout@v4 - name: Create PR from dev* to main @@ -27,4 +23,3 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh pr create --base main --head ${{ github.head_ref }} --title "Auto PR: ${{ github.head_ref }} to main" --body "Automated PR from dev* branch to main by workflow." - if: steps.org-check.outcome == 'success'