MENTIONS edges from the Route `route_qn` whose properties hold `part`. */
| 151 | |
| 152 | /* MENTIONS edges from the Route `route_qn` whose properties hold `part`. */ |
| 153 | static int oa_db_mentions_props(const char *db, const char *route_qn, const char *part) { |
| 154 | sqlite3 *h = NULL; |
| 155 | int n = 0; |
| 156 | if (sqlite3_open_v2(db, &h, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) { |
| 157 | sqlite3_close(h); |
| 158 | return -1; |
| 159 | } |
| 160 | sqlite3_stmt *st = NULL; |
| 161 | const char *sql = "SELECT count(*) FROM edges e JOIN nodes s ON s.id = e.source_id " |
| 162 | "WHERE e.type = 'MENTIONS' AND s.qualified_name = ?1 " |
| 163 | "AND e.properties LIKE '%' || ?2 || '%'"; |
| 164 | if (sqlite3_prepare_v2(h, sql, -1, &st, NULL) == SQLITE_OK) { |
| 165 | sqlite3_bind_text(st, 1, route_qn, -1, SQLITE_TRANSIENT); |
| 166 | sqlite3_bind_text(st, 2, part, -1, SQLITE_TRANSIENT); |
| 167 | if (sqlite3_step(st) == SQLITE_ROW) { |
| 168 | n = sqlite3_column_int(st, 0); |
| 169 | } |
| 170 | } |
| 171 | sqlite3_finalize(st); |
| 172 | sqlite3_close(h); |
| 173 | return n; |
| 174 | } |
| 175 | |
| 176 | static int oa_db_nodes(const char *db, const char *label, const char *qn) { |
| 177 | sqlite3 *h = NULL; |