Skip to content

Commit

Permalink
plugin filter yanked ones
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhou121 committed Nov 5, 2022
1 parent f374f36 commit 97d0e40
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 69 deletions.
12 changes: 8 additions & 4 deletions nginx/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
<html>
<head>
<title>Lapce Plugins</title>
<link rel="stylesheet" href="/static/main.css?id=da26a5870bfeb90d">
<link rel="preload" href="/static/main.wasm?id=da26a5870bfeb90d" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/static/main.js?id=da26a5870bfeb90d">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="/static/main.css?id=da26a5870bfeb90f">
<link rel="preload" href="/static/main.wasm?id=da26a5870bfeb90f" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/static/main.js?id=da26a5870bfeb90f">
</head>
<body class = "bg-body text-body font-body">
<script type="module">import init from '/static/main.js?id=da26a5870bfeb90d';init('/static/main.wasm?id=da26a5870bfeb90d');</script>
<script type="module">
import init from '/static/main.js?id=da26a5870bfeb90f';
init('/static/main.wasm?id=da26a5870bfeb90f');
</script>
</body>
</html>
59 changes: 0 additions & 59 deletions src/db/schema.rs

This file was deleted.

28 changes: 25 additions & 3 deletions volts-back/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ pub async fn search(
let limit = query.limit.unwrap_or(10).min(100);
let offset = query.offset.unwrap_or(0);
let mut conn = db_pool.read.get().await.unwrap();
let mut sql_query = plugins::table.inner_join(users::dsl::users).into_boxed();
let mut sql_query = plugins::table
.inner_join(users::dsl::users)
.filter(diesel::expression::exists::exists(
versions::table
.filter(versions::plugin_id.eq(plugins::id))
.filter(versions::yanked.eq(false)),
))
.into_boxed();
let mut total: i64 = 0;
let mut had_query = false;
if let Some(q) = query.q.as_ref() {
Expand All @@ -71,20 +78,35 @@ pub async fn search(

let filter = plugins::name
.ilike(q.clone())
.or(plugins::description.ilike(q));
.or(plugins::description.ilike(q.clone()))
.or(plugins::display_name.ilike(q));
sql_query = sql_query.filter(filter.clone());

had_query = true;
total = plugins::table
.filter(filter)
.filter(diesel::expression::exists::exists(
versions::table
.filter(versions::plugin_id.eq(plugins::id))
.filter(versions::yanked.eq(false)),
))
.count()
.get_result(&mut conn)
.await
.unwrap();
}
}
if !had_query {
total = plugins::table.count().get_result(&mut conn).await.unwrap();
total = plugins::table
.filter(diesel::expression::exists::exists(
versions::table
.filter(versions::plugin_id.eq(plugins::id))
.filter(versions::yanked.eq(false)),
))
.count()
.get_result(&mut conn)
.await
.unwrap();
}

sql_query = sql_query.offset(offset as i64).limit(limit as i64);
Expand Down
6 changes: 3 additions & 3 deletions volts-front/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<meta charset="utf-8">


<link rel="preload" href="/volts-front-34b9599a2389c6dd_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/volts-front-34b9599a2389c6dd.js"></head>
<link rel="preload" href="/volts-front-464e292a05f3a5fb_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/volts-front-464e292a05f3a5fb.js"></head>
<body class="bg-body text-body font-body">


<script type="module">import init from '/volts-front-34b9599a2389c6dd.js';init('/volts-front-34b9599a2389c6dd_bg.wasm');</script><script>(function () {
<script type="module">import init from '/volts-front-464e292a05f3a5fb.js';init('/volts-front-464e292a05f3a5fb_bg.wasm');</script><script>(function () {
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
var url = protocol + '//' + window.location.host + '/_trunk/ws';
var poll_interval = 5000;
Expand Down

0 comments on commit 97d0e40

Please sign in to comment.