| 1 |
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
| 2 |
/*
|
| 3 |
* article_view_log
|
| 4 |
* - data persistence and query of article view log
|
| 5 |
*
|
| 6 |
* Copyright (C) 2004-2026 Leaflet <leaflet@leafok.com>
|
| 7 |
*/
|
| 8 |
|
| 9 |
#ifndef _ARTICLE_VIEW_LOG_H_
|
| 10 |
#define _ARTICLE_VIEW_LOG_H_
|
| 11 |
|
| 12 |
#include <stdint.h>
|
| 13 |
|
| 14 |
enum article_view_log_constant_t
|
| 15 |
{
|
| 16 |
MAX_VIEWED_AID_INC_CNT = 1000,
|
| 17 |
};
|
| 18 |
|
| 19 |
struct article_view_log_t
|
| 20 |
{
|
| 21 |
int uid;
|
| 22 |
int32_t *aid_base;
|
| 23 |
int aid_base_cnt;
|
| 24 |
int32_t aid_inc[MAX_VIEWED_AID_INC_CNT];
|
| 25 |
int aid_inc_cnt;
|
| 26 |
};
|
| 27 |
typedef struct article_view_log_t ARTICLE_VIEW_LOG;
|
| 28 |
|
| 29 |
extern ARTICLE_VIEW_LOG BBS_article_view_log;
|
| 30 |
|
| 31 |
// Load baseline view log from DB
|
| 32 |
extern int article_view_log_load(int uid, ARTICLE_VIEW_LOG *p_view_log, int keep_inc);
|
| 33 |
// Clear data
|
| 34 |
extern int article_view_log_unload(ARTICLE_VIEW_LOG *p_view_log);
|
| 35 |
// Save incremental view log to DB
|
| 36 |
extern int article_view_log_save_inc(const ARTICLE_VIEW_LOG *p_view_log);
|
| 37 |
// Merge incremental view log to baseline, without DB read / write
|
| 38 |
extern int article_view_log_merge_inc(ARTICLE_VIEW_LOG *p_view_log);
|
| 39 |
|
| 40 |
// Check if specific article was viewed
|
| 41 |
extern int article_view_log_is_viewed(int32_t aid, const ARTICLE_VIEW_LOG *p_view_log);
|
| 42 |
// Set specific article as viewed
|
| 43 |
extern int article_view_log_set_viewed(int32_t aid, ARTICLE_VIEW_LOG *p_view_log);
|
| 44 |
|
| 45 |
#endif //_ARTICLE_VIEW_LOG_H_
|