| 3 |
* user_stat |
* user_stat |
| 4 |
* - data model and basic operations of user related statistics |
* - data model and basic operations of user related statistics |
| 5 |
* |
* |
| 6 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
* Copyright (C) 2004-2026 Leaflet <leaflet@leafok.com> |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
| 19 |
{ |
{ |
| 20 |
if (p_map == NULL) |
if (p_map == NULL) |
| 21 |
{ |
{ |
| 22 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 23 |
return -1; |
return -1; |
| 24 |
} |
} |
| 25 |
|
|
| 40 |
|
|
| 41 |
if (p_map == NULL) |
if (p_map == NULL) |
| 42 |
{ |
{ |
| 43 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 44 |
return -1; |
return -1; |
| 45 |
} |
} |
| 46 |
|
|
| 47 |
// Load uid_list |
// Load uid_list |
| 48 |
if (get_user_id_list(uid_list, &user_cnt, p_map->last_uid + 1) < 0) |
if (get_user_id_list(uid_list, &user_cnt, p_map->last_uid + 1) < 0) |
| 49 |
{ |
{ |
| 50 |
log_error("get_user_id_list(%d, 0) error\n", user_cnt); |
log_error("get_user_id_list(%d, 0) error", user_cnt); |
| 51 |
return -2; |
return -2; |
| 52 |
} |
} |
| 53 |
|
|
| 67 |
p_article = article_block_find_by_index(i); |
p_article = article_block_find_by_index(i); |
| 68 |
if (p_article == NULL) |
if (p_article == NULL) |
| 69 |
{ |
{ |
| 70 |
log_error("article_block_find_by_index(index=%d) error\n", i); |
log_error("article_block_find_by_index(index=%d) error", i); |
| 71 |
break; |
break; |
| 72 |
} |
} |
| 73 |
|
|
| 78 |
|
|
| 79 |
if (p_article->uid > p_map->last_uid) |
if (p_article->uid > p_map->last_uid) |
| 80 |
{ |
{ |
| 81 |
#ifdef _DEBUG |
log_debug("uid=%d of article(aid=%d) is greater than last_uid=%d", |
|
log_error("uid=%d of article(aid=%d) is greater than last_uid=%d\n", |
|
| 82 |
p_article->uid, p_article->aid, p_map->last_uid); |
p_article->uid, p_article->aid, p_map->last_uid); |
|
#endif |
|
| 83 |
continue; |
continue; |
| 84 |
} |
} |
| 85 |
|
|
| 86 |
if (user_stat_article_cnt_inc(p_map, p_article->uid, 1) < 0) |
if (user_stat_article_cnt_inc(p_map, p_article->uid, 1) < 0) |
| 87 |
{ |
{ |
| 88 |
log_error("user_stat_article_cnt_inc(uid=%d, 1) error\n", p_article->uid); |
log_error("user_stat_article_cnt_inc(uid=%d, 1) error", p_article->uid); |
| 89 |
break; |
break; |
| 90 |
} |
} |
| 91 |
} |
} |
| 103 |
|
|
| 104 |
if (p_map == NULL) |
if (p_map == NULL) |
| 105 |
{ |
{ |
| 106 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 107 |
return -1; |
return -1; |
| 108 |
} |
} |
| 109 |
|
|
| 145 |
|
|
| 146 |
if (p_map == NULL) |
if (p_map == NULL) |
| 147 |
{ |
{ |
| 148 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 149 |
return -1; |
return -1; |
| 150 |
} |
} |
| 151 |
|
|