Skip to content

Commit 28fd747

Browse files
committed
wip: port endpoints
1 parent f1fce50 commit 28fd747

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

src/lib/src/api/local/compare/join_compare.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::api::local::diff;
12
use crate::error::OxenError;
23

34
use polars::prelude::ChunkCompare;
@@ -19,7 +20,7 @@ pub fn compare(
1920
let left_only_df = calculate_left_df(&joined_df, targets.clone(), keys.clone())?;
2021
let right_only_df = calculate_right_df(&joined_df, targets.clone(), keys.clone())?;
2122

22-
Ok((match_df, diff_df, left_only_df, right_only_df))
23+
Ok((diff_df, match_df, left_only_df, right_only_df))
2324
}
2425

2526
fn join_hashed_dfs(

src/server/src/controllers/compare.rs

+31-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::params::{
2727
self, app_data, df_opts_query, parse_base_head, path_param, resolve_base_head, DFOptsQuery,
2828
PageNumQuery,
2929
};
30+
use liboxen::model::entry::commit_entry::CompareEntry;
3031

3132
pub async fn commits(
3233
req: HttpRequest,
@@ -166,15 +167,26 @@ pub async fn create_df_compare(
166167
OxenError::ResourceNotFound(format!("{}@{}", resource_2.display(), commit_2).into())
167168
})?;
168169

170+
let cpath_1 = CompareEntry {
171+
commit_entry: Some(entry_1),
172+
path: resource_1,
173+
};
174+
175+
let cpath_2 = CompareEntry {
176+
commit_entry: Some(entry_2),
177+
path: resource_2,
178+
};
179+
169180
let compare = api::local::compare::compare_files(
170181
&repository,
171182
Some(&compare_id),
172-
entry_1,
173-
entry_2,
183+
cpath_1,
184+
cpath_2,
174185
keys,
175186
targets,
176187
None,
177-
)?;
188+
)?
189+
.ok_or_else(|| OxenError::basic_str("Error creating comparison"))?;
178190

179191
let mut messages: Vec<OxenMessage> = vec![];
180192

@@ -227,11 +239,21 @@ pub async fn get_df_compare(
227239
OxenError::ResourceNotFound(format!("{}@{}", data.right_resource, right_commit).into())
228240
})?;
229241

242+
let cpath_1 = CompareEntry {
243+
commit_entry: Some(left_entry.clone()),
244+
path: left_entry.path,
245+
};
246+
247+
let cpath_2 = CompareEntry {
248+
commit_entry: Some(right_entry.clone()),
249+
path: right_entry.path,
250+
};
251+
230252
let maybe_cached_compare = api::local::compare::get_cached_compare(
231253
&repository,
232254
&compare_id,
233-
&left_entry,
234-
&right_entry,
255+
cpath_1.clone(),
256+
cpath_2.clone(),
235257
)?;
236258

237259
let view = match maybe_cached_compare {
@@ -254,12 +276,13 @@ pub async fn get_df_compare(
254276
let compare = api::local::compare::compare_files(
255277
&repository,
256278
Some(&compare_id),
257-
left_entry,
258-
right_entry,
279+
cpath_1,
280+
cpath_2,
259281
data.keys,
260282
data.targets,
261283
None,
262-
)?;
284+
)?
285+
.ok_or_else(|| OxenError::basic_str("Error creating comparison"))?;
263286

264287
let mut messages: Vec<OxenMessage> = vec![];
265288

0 commit comments

Comments
 (0)