Skip to content

Commit 5cf5c37

Browse files
bors[bot]meili-botcurquiza
authored
Merge #201
201: Changes related to the next MeiliSearch release (v0.24.0) r=curquiza a=meili-bot Related to this issue: meilisearch/integration-guides#149 This PR: - gathers the changes related to the next MeiliSearch release (v0.24.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases). - might eventually contain test failures until the MeiliSearch v0.24.0 is out. ⚠️ This PR should NOT be merged until the next release of MeiliSearch (v0.24.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose._ Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com> Co-authored-by: Clémentine Urquizar - curqui <clementine@meilisearch.com> Co-authored-by: Clémentine Urquizar <clementine@meilisearch.com>
2 parents d26d509 + fc26ca3 commit 5cf5c37

File tree

11 files changed

+185
-148
lines changed

11 files changed

+185
-148
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extensi
190190

191191
## 🤖 Compatibility with MeiliSearch
192192

193-
This package only guarantees the compatibility with the [version v0.23.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.23.0).
193+
This package only guarantees the compatibility with the [version v0.24.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.24.0).
194194

195195
## ⚙️ Development Workflow and Contributing
196196

README.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extensi
9797

9898
## 🤖 Compatibility with MeiliSearch
9999

100-
This package only guarantees the compatibility with the [version v0.23.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.23.0).
100+
This package only guarantees the compatibility with the [version v0.24.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.24.0).
101101

102102
## ⚙️ Development Workflow and Contributing
103103

examples/web_app/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ edition = "2018"
88
crate-type = ["cdylib", "rlib"]
99

1010
[dependencies]
11+
serde_json = "1.0"
1112
wasm-bindgen = "0.2"
1213
wasm-bindgen-futures = "0.4.18"
1314
yew = "0.18"

examples/web_app/src/document.rs

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use meilisearch_sdk::document::Document;
22
use serde::{Deserialize, Serialize};
3+
use serde_json::{Map, Value};
34
use yew::prelude::*;
45

56
#[derive(Debug, Serialize, Deserialize)]
@@ -22,58 +23,56 @@ impl Document for Crate {
2223
}
2324
}
2425

25-
impl Crate {
26-
27-
pub fn get_readable_download_count(&self) -> String {
28-
if let Some(downloads) = self.downloads {
29-
if downloads < 1000 {
30-
downloads.to_string()
31-
} else if downloads < 1000000 {
32-
format!("{:.1}k", downloads as f64 / 1000.0)
33-
} else {
34-
format!("{:.1}M", downloads as f64 / 1000000.0)
35-
}
26+
27+
fn get_readable_download_count(this: &Map<String, Value>) -> String {
28+
if let Some(downloads) = this["downloads"].as_f64() {
29+
if downloads < 1000.0 {
30+
downloads.to_string()
31+
} else if downloads < 1000000.0 {
32+
format!("{:.1}k", downloads / 1000.0)
3633
} else {
37-
String::from("?")
34+
format!("{:.1}M", downloads / 1000000.0)
3835
}
36+
} else {
37+
String::from("?")
3938
}
39+
}
4040

41-
pub fn display(&self) -> Html {
42-
let mut url = format!("https://lib.rs/crates/{}", self.name);
43-
url = url.replace("<em>", "");
44-
url = url.replace("</em>", "");
41+
pub fn display(this: &Map<String, Value>) -> Html {
42+
let mut url = format!("https://lib.rs/crates/{}", this["name"].as_str().unwrap_or_default());
43+
url = url.replace("<em>", "");
44+
url = url.replace("</em>", "");
4545

46-
html! {
47-
<li><a href=url>
48-
<div class="h">
49-
<h4>
50-
{
51-
// This field is formatted so we don't want Yew to escape the HTML tags
52-
unescaped_html(&self.name)
53-
}
54-
</h4>
55-
<p class="desc">{unescaped_html(&self.description)}</p>
56-
</div>
57-
<div class="meta">
58-
<span class="version stable">
59-
<span>{"v"}</span>
60-
{&self.version}
61-
</span>
62-
<span class="downloads" title=format!("{} recent downloads", self.downloads.unwrap_or(0))>
63-
{self.get_readable_download_count()}
64-
</span>
65-
{for self.keywords.iter().map(|keyword|
66-
html! {
67-
<span class="k">
68-
<span>{"#"}</span>
69-
{keyword}
70-
</span>
71-
}
72-
)}
73-
</div>
46+
html! {
47+
<li><a href=url>
48+
<div class="h">
49+
<h4>
50+
{
51+
// This field is formatted so we don't want Yew to escape the HTML tags
52+
unescaped_html(&this["name"].as_str().unwrap_or_default())
53+
}
54+
</h4>
55+
<p class="desc">{unescaped_html(&this["description"].as_str().unwrap_or_default())}</p>
56+
</div>
57+
<div class="meta">
58+
<span class="version stable">
59+
<span>{"v"}</span>
60+
{&this["version"].as_str().unwrap_or_default()}
61+
</span>
62+
<span class="downloads" title=format!("{} recent downloads", this["downloads"].as_f64().unwrap_or(0.0))>
63+
{get_readable_download_count(this)}
64+
</span>
65+
{for this["keywords"].as_array().unwrap().iter().map(|keyword|
66+
html! {
67+
<span class="k">
68+
<span>{"#"}</span>
69+
{keyword.as_str().unwrap_or_default()}
70+
</span>
71+
}
72+
)}
73+
</div>
7474

75-
</a></li>
76-
}
75+
</a></li>
7776
}
7877
}
7978

examples/web_app/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ use meilisearch_sdk::{
44
indexes::Index,
55
search::{SearchResults, Selectors::All},
66
};
7+
use serde_json::{Map, Value};
78
use std::rc::Rc;
89
use wasm_bindgen::prelude::*;
910
use wasm_bindgen_futures::spawn_local;
1011
use yew::prelude::*;
1112
use lazy_static::lazy_static;
1213

1314
mod document;
14-
use crate::document::Crate;
15+
use crate::document::{Crate, display};
1516

1617
lazy_static! {
1718
static ref CLIENT: Client = Client::new(
@@ -23,7 +24,7 @@ lazy_static! {
2324
struct Model {
2425
link: Rc<ComponentLink<Self>>,
2526
index: Rc<Index>,
26-
results: Vec<Crate>,
27+
results: Vec<Map<String, Value>>,
2728
processing_time_ms: usize,
2829

2930
// These two fields are used to avoid rollbacks by giving an ID to each request
@@ -35,7 +36,7 @@ enum Msg {
3536
/// An event sent to update the results with a query
3637
Input(String),
3738
/// The event sent to display new results once they are received
38-
Update{results: Vec<Crate>, processing_time_ms: usize, request_id: usize},
39+
Update{results: Vec<Map<String, Value>>, processing_time_ms: usize, request_id: usize},
3940
}
4041

4142
impl Component for Model {
@@ -126,7 +127,7 @@ impl Component for Model {
126127
<ol id="handlebars-list">
127128
{
128129
// Display the results
129-
for self.results.iter().map(|r| r.display())
130+
for self.results.iter().map(|r| display(r))
130131
}
131132
</ol>
132133
</div>

src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl Client {
179179
match self.delete_index(uid).await {
180180
Ok (_) => Ok(true),
181181
Err (Error::MeiliSearchError {
182-
message: _,
182+
error_message: _,
183183
error_code: ErrorCode::IndexNotFound,
184184
error_type: _,
185185
error_link: _,

0 commit comments

Comments
 (0)