MCPcopy Create free account
hub / github.com/Moosync/Moosync / increment_play_count

Method increment_play_count

src-tauri/database/src/database.rs:1124–1150  ·  view source on GitHub ↗
(&self, id: String)

Source from the content-addressed store, hash-verified

1122
1123 #[tracing::instrument(level = "debug", skip(self))]
1124 pub fn increment_play_count(&self, id: String) -> Result<()> {
1125 trace!("Incrementing play count");
1126 let mut conn = self.pool.get().unwrap();
1127 let play_count = QueryDsl::select(analytics, schema::analytics::play_count)
1128 .filter(schema::analytics::song_id.eq(id.clone()))
1129 .first::<Option<i32>>(&mut conn);
1130
1131 if play_count.is_err() {
1132 insert_into(analytics)
1133 .values(Analytics {
1134 id: Some(Uuid::new_v4().to_string()),
1135 song_id: Some(id),
1136 play_count: Some(1),
1137 play_time: Some(0f64),
1138 })
1139 .execute(&mut conn)?;
1140 return Ok(());
1141 }
1142
1143 update(analytics)
1144 .filter(schema::analytics::song_id.eq(id))
1145 .set(schema::analytics::play_count.eq(schema::analytics::play_count + 1))
1146 .execute(&mut conn)?;
1147
1148 info!("Incremented play count");
1149 Ok(())
1150 }
1151
1152 #[tracing::instrument(level = "debug", skip(self))]
1153 pub fn increment_play_time(&self, id: String, duration: f64) -> Result<()> {

Callers 2

test_remove_songsFunction · 0.80
test_analyticsFunction · 0.80

Calls 4

getMethod · 0.80
cloneMethod · 0.80
setMethod · 0.80
eqMethod · 0.45

Tested by 2

test_remove_songsFunction · 0.64
test_analyticsFunction · 0.64