Abstract out the last remaining SQL queries in timer_retrieve_feeds()

This commit is contained in:
2024-11-25 00:36:40 -05:00
parent 23ed4a7d96
commit 69be63aa2e
3 changed files with 87 additions and 47 deletions

View File

@ -27,15 +27,30 @@ typedef enum {
ZBLOCK_FEED_INFO_DBERROR,
ZBLOCK_FEED_INFO_EXISTS,
ZBLOCK_FEED_INFO_NOT_EXIST,
ZBLOCK_FEED_INFO_FINISHED,
ZBLOCK_FEED_INFO_NOMEM,
ZBLOCK_FEED_INFO_ERRORCOUNT
} zblock_feed_info_err;
// free all information associated with a minimal feed info struct (does not assume the struct was allocated using malloc)
void zblock_feed_info_minimal_free(zblock_feed_info_minimal *feed_info);
// free all information associated with a feed info struct (does not assume the struct was allocated using malloc)
void zblock_feed_info_free(zblock_feed_info *feed_info);
// maybe change the function signature so you can actually do error handling with the result?
time_t pubDate_to_time_t(char *s);
// returns a string about the result of a feed_info function
const char *zblock_feed_info_strerror(zblock_feed_info_err error);
// Begin retrieval of feed info objects.
zblock_feed_info_err zblock_feed_info_retrieve_list_begin(PGconn *conn);
// Retrieve the next feed list object.
// On error, no more objects can be retrieved and the returned object is invalid.
zblock_feed_info_err zblock_feed_info_retrieve_list_item(PGconn *conn, zblock_feed_info_minimal *feed_info);
// check if the feed currently exists. the result is in the exists pointer.
zblock_feed_info_err zblock_feed_info_exists(PGconn *conn, const char *url, u64snowflake channel_id, int *exists);