send new sessions on fetch

This commit is contained in:
Nikita Galaiko 2023-05-10 10:16:45 +02:00
parent 0b977613b1
commit 9eaef82393
2 changed files with 25 additions and 2 deletions

View File

@ -23,6 +23,11 @@ impl<'listener> Handler<'listener> {
}
pub fn handle(&self, project: &projects::Project) -> Result<Vec<events::Event>> {
let sessions_before_fetch = self
.gb_repository
.get_sessions_iterator()?
.filter_map(|s| s.ok())
.collect::<Vec<_>>();
if !self.gb_repository.fetch().context("failed to fetch")? {
return Ok(vec![]);
}
@ -41,6 +46,24 @@ impl<'listener> Handler<'listener> {
..Default::default()
})
.context("failed to update project")?;
Ok(vec![])
let sessions_after_fetch = self
.gb_repository
.get_sessions_iterator()?
.filter_map(|s| s.ok())
.collect::<Vec<_>>();
let new_sessions = sessions_after_fetch
.iter()
.filter(|s| !sessions_before_fetch.contains(s))
.collect::<Vec<_>>();
let events = new_sessions
.into_iter()
.cloned()
.map(|session| events::Event::Session((project.clone(), session)))
.collect::<Vec<_>>();
Ok(events)
}
}

View File

@ -64,7 +64,7 @@
const description = formData.get('description') as string | undefined;
try {
if (name) {
if ($project.api && name) {
const updated = await cloud.projects.update(
$user.access_token,
$project.api.repository_id,