tango-core 0.3.0

The tango schema, entities, migrations, and search contract
Documentation
use sea_orm_migration::prelude::*;

/// Widens the discussion-density signal, and makes `require_all` satisfiable.
///
/// `context_matches` was a +-30 s window. On the sample that nearly did not
/// discriminate: each video's window peaked at 2 while some videos had 18
/// matching cues, so 119 of 165 rows for `dark root basin` scored 1 and the
/// tie-break above `rank` was close to arbitrary. At +-300 s the tail appears -
/// a handful of passages carry eight or more mentions in ten minutes - which is
/// what "this segment is about the term" looks like in this corpus. Thirty
/// seconds was measuring whether the speaker repeated the word in one breath,
/// a thing the utterance merge in f5aa277 had already removed from storage.
///
/// `require_all` demanded every term in the same cue, so `dark root basin`
/// returned nothing - not because no video says those words, but because no
/// sixteen-word utterance holds all three at once. It is now satisfied by the
/// video's deduplicated body, where the terms can actually co-occur, while the
/// cue scan stays any-term so a video that discusses the phrase returns its
/// cues with `matched_terms` naming how much of it each one carries.
///
/// An earlier draft fell back to any-term when nothing satisfied the strict
/// query and was removed: silently returning the whole loose set is the failure
/// the flag exists to prevent. `total = 0` is predictable, whereas a total that
/// means something else depending on whether the phrase exists is not.
///
/// Both functions resolve the scan through `transcript_scan_query`, because a
/// page and its total disagreeing about which query ran is a defect that would
/// surface exactly when a caller trusts the total most.
///
/// `search_video_transcript` is added for the "5 more matches in this video"
/// interaction. The `video_id` filter on the main endpoint already lists a
/// video's matching cues; this adds the one thing it cannot, a sequential
/// `moment` number, so a client can group the rolling repeats around one
/// mention without recomputing the gap itself.
#[derive(DeriveMigrationName)]
pub struct Migration;

const UP: &str = include_str!("sql/0023_discussion_density.sql");

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager.get_connection().execute_unprepared(UP).await?;
        Ok(())
    }

    async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
        // A no-op, like 0010 onwards: the reverse means dropping the wider window
        // back to a signal that did not discriminate, and dropping a query
        // resolver two functions now share.
        Ok(())
    }
}