/[LeafOK_CVS]/lbbs/src/user_stat.c
ViewVC logotype

Diff of /lbbs/src/user_stat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Thu Oct 23 04:09:33 2025 UTC Revision 1.9 by sysadm, Sat Jan 3 10:27:14 2026 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                   user_list.c  -  description  /*
3                                                           -------------------   * user_stat
4          Copyright            : (C) 2004-2025 by Leaflet   *   - data model and basic operations of user related statistics
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2026  Leaflet <leaflet@leafok.com>
7     */
8  /***************************************************************************  
9   *                                                                         *  #ifdef HAVE_CONFIG_H
10   *   This program is free software; you can redistribute it and/or modify  *  #include "config.h"
11   *   it under the terms of the GNU General Public License as published by  *  #endif
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
12    
13  #include "log.h"  #include "log.h"
14  #include "section_list.h"  #include "section_list.h"
# Line 23  int user_stat_map_init(USER_STAT_MAP *p_ Line 19  int user_stat_map_init(USER_STAT_MAP *p_
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    
# Line 44  int user_stat_map_update(USER_STAT_MAP * Line 40  int user_stat_map_update(USER_STAT_MAP *
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    
# Line 71  int user_stat_map_update(USER_STAT_MAP * Line 67  int user_stat_map_update(USER_STAT_MAP *
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    
74                    if (p_article->visible == 0)
75                    {
76                            continue;
77                    }
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, waiting for next user list update\n",  
82                                            p_article->uid, p_article->aid, p_map->last_uid);                                            p_article->uid, p_article->aid, p_map->last_uid);
83  #endif                          continue;
                         break;  
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          }          }
# Line 104  int user_stat_article_cnt_inc(USER_STAT_ Line 103  int user_stat_article_cnt_inc(USER_STAT_
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    
# Line 116  int user_stat_article_cnt_inc(USER_STAT_ Line 115  int user_stat_article_cnt_inc(USER_STAT_
115                  mid = (left + right) / 2;                  mid = (left + right) / 2;
116                  if (uid < p_map->stat_list[mid].uid)                  if (uid < p_map->stat_list[mid].uid)
117                  {                  {
118                          right = mid;                          right = mid - 1;
119                  }                  }
120                  else if (uid > p_map->stat_list[mid].uid)                  else if (uid > p_map->stat_list[mid].uid)
121                  {                  {
# Line 146  int user_stat_get(USER_STAT_MAP *p_map, Line 145  int user_stat_get(USER_STAT_MAP *p_map,
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    
# Line 158  int user_stat_get(USER_STAT_MAP *p_map, Line 157  int user_stat_get(USER_STAT_MAP *p_map,
157                  mid = (left + right) / 2;                  mid = (left + right) / 2;
158                  if (uid < p_map->stat_list[mid].uid)                  if (uid < p_map->stat_list[mid].uid)
159                  {                  {
160                          right = mid;                          right = mid - 1;
161                  }                  }
162                  else if (uid > p_map->stat_list[mid].uid)                  else if (uid > p_map->stat_list[mid].uid)
163                  {                  {


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1