Online duration statistics method and device and computer readable storage medium
By setting a preset statistical duration model on the client and server to calculate the user's online time, the roughness and resource occupation problems in the existing technology are solved, and accurate online time statistics and efficient time calibration are achieved.
Patent Information
- Application Number
- CN202211643054.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-12-20
AI Technical Summary
The existing technology for calculating the online time of users is crude and occupies server resources, cannot accurately calculate, and the user's modification time leads to inaccurate results.
By setting a preset statistical duration model on the client and server, the difference between the client local time and the server system time when the user logs in is calculated, and the difference is summed with the time difference when the interface is first called to obtain the user's online duration and reduce the frequency of server resource calls.
It achieves the accurate calculation of user online time without frequent calls to server resources, improves statistical efficiency and accuracy, and adapts to scenarios where users modify their time and log in at different times.
Smart Images

Figure CN116132500B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of user online time, and in particular to a method and device for counting online time, and a computer-readable storage medium. Background Art
[0002] Typically, each client sends a login request to the server when pre-logging into a target application. Once the client authorizes the login, a login confirmation message is sent back, allowing the client to log into the target application. When the client logs out of the target application, the server also receives a logout notification. User online time is typically calculated by taking the difference between the time the user first logged in and the time they last logged out.
[0003] Currently, this simple calculation method is relatively crude and cannot accurately calculate a user's actual online time. Although a traditional technique currently exists that obtains the time through multiple requests and then calculates the online time by subtracting them, each request consumes server resources and requires time determination each time, which is cumbersome and laborious. Summary of the Invention
[0004] In view of this, the purpose of the embodiments of the present application is to provide an online time statistics method, device and computer-readable storage medium, which are applied to the client and / or server, and calculate the difference between the client local time when the user logs in and the server system time when the user logs in by setting a preset statistical time model, and then sum it with the difference between the server system time when the user first calls the interface and the client local time when the user first logs in, and finally calculate the user's online time; it is achieved that even if the server resources are not called frequently, the accurate user online time can be obtained; it is achieved that even when the server time is inconsistent with the client time, the accurate user online time can be obtained; it is achieved that when the user logs in to the server at different times, the statistical online time is still accurate, thereby solving the above-mentioned technical problems of "insufficient accuracy, occupying server resources, and more cumbersome processing".
[0005] In the first aspect, an embodiment of the present application provides an online duration statistics method, which is applied to a client, and the client is communicated with a server; the method includes: obtaining the user login server time, the user login client local time, the user's first call to the online duration interface server time and the user's first login to the client local time from the server; substituting the user login server time, the user login client local time, the user's first call to the online duration interface server time and the user's first login to the client local time into a preset statistical duration model for calculation to obtain the online duration.
[0006] In the above implementation process, by using the online time statistics method applied to the client, the client only needs to connect to the server once to obtain the accurate online time. Even if the user automatically modifies the server system time, the accurate online time can be obtained. Even if the client time used by the user is different, the obtained user online time is also accurate. There is no need to frequently call the interface to obtain the time, which reduces the interaction between the client and the server and improves the efficiency and accuracy of online time statistics.
[0007] Optionally, after the online time is obtained by substituting the user login server time, the user login client local time, the user first call online time interface server time, and the user first login client local time into a preset statistical time model for calculation, the method further includes: returning the online time to the server side for display through the called online time interface.
[0008] In the above implementation process, the online duration interface is called to return data for display, which is fast and effective, and improves the user experience.
[0009] Optionally, the preset statistical duration model includes: the online duration is equal to the sum of a first difference and a second difference; wherein, the first difference is the difference between the local time when the user logs into the client and the time when the user logs into the server; the second difference is the difference between the time when the user first calls the online duration interface server and the time when the user first logs into the local client.
[0010] In the above implementation process, the difference between the client local time when the user logs in and the server system time when the user logs in is summed with the difference between the server system time when the user first calls the interface and the client local time when the user first logs in, and finally the user's online time is calculated as the idea of preset statistical time model. There is no need to frequently call the interface to obtain time, which reduces the interaction between the client and the server, and improves the efficiency and accuracy of online time statistics.
[0011] Optionally, after the online duration is obtained by substituting the user login server time, the user login client local time, the user's first call to the online duration interface server time, and the user's first login client local time into a preset statistical duration model for calculation, the method further includes: obtaining the increase time of a preset timer; and accumulating and updating the online duration according to the increase time.
[0012] In the above implementation process, by adding a preset timer to accumulate and update the online time, it can prevent users from modifying the local time or server system time after logging in, which may lead to inaccurate final results. It can also avoid data loss in the event of an unexpected termination of the server, thereby improving the efficiency and accuracy of online time statistics.
[0013] Optionally, after the online duration is cumulatively updated according to the added time, the method further includes: determining whether the user login server time is consistent with the user login client local time; if the user login server time is inconsistent with the user login client local time, substituting the user login server time calculated by the preset statistical duration model into the user login server time before the inconsistency, so as to perform time calibration on the online duration.
[0014] In the above implementation process, the accuracy of the online duration can be further verified through time calibration. The client only needs to connect to the server once to obtain the accurate online duration. The time can be calibrated again by calling the interface afterwards to make the time more accurate without occupying server resources. This allows clients with different local times to log in and obtain accurate online duration, thereby improving the efficiency and accuracy of online duration statistics.
[0015] In the second aspect, an embodiment of the present application provides an online time statistics method, which is applied to a server side, and the server side is communicatively connected to a client side. The method includes: detecting a user's login to the client, and when the user logs in to the client, creating a database to store the user's login time to the server and the user's login time to the client local time; wherein, the user's login time to the client local time includes: the user's first login time to the client local time; when a user's viewing operation on the online time is detected, calling the online time interface and passing the user's login time to the server, the user's login time to the client local time, and the user's call to the online time interface server time to the client, so that the client calculates the online time according to a preset statistical time model; wherein, the user's call to the online time interface server time includes: the user's first call to the online time interface server time.
[0016] In the above implementation process, by using the online time statistics method applied to the server, the client only needs to connect to the server once to obtain the accurate online time. Even if the user automatically modifies the server system time, the accurate online time can be obtained. Even if the client time used by the user is different, the obtained user online time is also accurate. There is no need to frequently call the interface to obtain the time, which reduces the interaction between the client and the server and improves the efficiency and accuracy of online time statistics.
[0017] In a third aspect, an embodiment of the present application provides an online duration statistics method, which is applied to a system including a client and a server, wherein the client is in communication with the server, and the method comprises: the server detects the user's login to the client, and when the user logs in to the client, creates a database to store the time when the user logs in to the server and the local time when the user logs in to the client; wherein the local time when the user logs in to the client includes the local time when the user logs in to the client for the first time; when the server detects the user's viewing operation on the online duration, the online duration interface is called and the user login server time and the local time when the user calls the online duration interface service are stored. The server time is transmitted to the client, so that the client calculates the online time according to the preset statistical time model; wherein, the time when the user calls the online time interface server includes: the time when the user calls the online time interface server for the first time; the client obtains the user login server time, the user login client local time, the user first call online time interface server time, and the user first login client local time from the server; the client substitutes the user login server time, the user login client local time, the user first call online time interface server time, and the user first login client local time into the preset statistical time model for calculation to obtain the online time.
[0018] In the above implementation process, through this online time statistics method applied to the client and server, a preset statistical time model is set based on four times, namely the client local time when the user logs in, the server system time when the user logs in, the server system time when the user first calls the interface, and the client local time when the user first logs in, and finally the user's online time is calculated; it is achieved that even when the server resources are not frequently called, the accurate user online time can be obtained; it is achieved that even when the server time is inconsistent with the client time, the accurate user online time can be obtained; it is achieved that even when the user logs in to the server at different times or the user automatically modifies the server system time, the accurate online time can still be counted; the interaction between the client and the server is reduced, and the efficiency and accuracy of online time statistics are improved.
[0019] In a fourth aspect, an embodiment of the present application provides an online time statistics device, which is applied to a client, and the client is communicatively connected to the server. The device includes: an acquisition module, which is used to obtain the user login server time, the user login client local time, the user's first call to the online time interface server time, and the user's first login to the client local time from the server; a calculation and statistics module, which is used to substitute the user login server time, the user login client local time, the user's first call to the online time interface server time, and the user's first login to the client local time into a preset statistical time model for calculation to obtain the online time.
[0020] In the fifth aspect, an embodiment of the present application provides an online time statistics device, which is applied to a server side, and the server side is communicatively connected to a client side. The device includes: a storage module, which is used to create a database to store the user login server time and the user login client local time when the user logs in to the client; wherein, the user login client local time includes: the user's first login to the client local time; a calling interface module, which is used to call the online time interface when the user checks the online time and pass the user login server time, the user login client local time, and the user calling the online time interface server time to the client to calculate the online time; wherein, the user calling the online time interface server time includes: the user calling the online time interface server time for the first time.
[0021] In a sixth aspect, an embodiment of the present application further provides an electronic device comprising: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the above method.
[0022] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are executed.
[0023] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the following embodiments are given in conjunction with the accompanying drawings for detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0025] Figure 1A flowchart of an online duration statistics method provided in an embodiment of the present application;
[0026] Figure 2 A flowchart of an online duration statistics method provided in an embodiment of the present application;
[0027] Figure 3 A flowchart of a method for counting online time applied to a client provided in an embodiment of the present application;
[0028] Figure 4 A flowchart of a method for counting online time applied to a server provided in an embodiment of the present application;
[0029] Figure 5 A schematic diagram of the module functions of an online duration statistics device for a client provided in an embodiment of the present application;
[0030] Figure 6 A schematic diagram of the module functions of an online duration statistics device applied to a server side provided in an embodiment of the present application;
[0031] Figure 7 A block diagram of an electronic device providing an online duration statistics device according to an embodiment of the present application.
[0032] Icons: 210 - acquisition module; 220 - calculation and statistics module; 230 - storage module; 240 - call interface module; 300 - electronic device; 311 - memory; 312 - storage controller; 313 - processor; 314 - peripheral interface; 315 - input and output unit; 316 - display unit. DETAILED DESCRIPTION
[0033] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work fall within the scope of protection of the present application.
[0034] It should be noted that similar numbers and letters represent similar items in the following figures, so once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. The terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element. The terms "first", "second", etc. are used only to distinguish descriptions and are not to be understood as indicating or implying relative importance.
[0035] The inventors of this application noticed that traditional technology obtains time through multiple requests and then calculates the online duration result by subtracting it. For example, the prior art mentions a technical solution for counting user online duration based on Java, which may specifically include: 1. The server sets an effective time interval value for calculating the user's online duration and assigns the user's online duration to zero; 2. The user sends a request to the server through a browser; 3. The server records the user's request sending time, and subtracts the adjacent last request sending time from the request sending time to obtain the time interval value; 4. If the time interval value is less than or equal to the effective time interval value, the server accumulates the time interval value to the user's online duration; 5. The user sends a request to the server through the browser again, and repeats steps 3 and 4; 6. The server is provided with a timer, and the timer sends a reminder to the server. After receiving the reminder, the server stores the user's online duration and the last request sending time in the database; 7. The timer sends a time reminder to the server at fixed intervals; 8. The server stores the user's online duration and the last request sending time persistently in the database.
[0036] The above solution is based on the user making multiple access requests on the browser, and then the server determines whether the time interval between the user's requests is within this valid time interval to calculate the online time. When calculating the user's online time, although a relatively accurate time can be calculated, there are certain performance issues because the timer sending reminders to the server will occupy the server's resources. Moreover, if the user does not send requests frequently, then this technical solution is not applicable, and the online time is still not accurate enough. In addition, if the user modifies the time on the server, then the user's online time calculated by this method will be even less accurate. In view of this, the embodiment of the present application provides an online time statistics method as described below.
[0037] See also Figure 1 ,Figure 1 This is a flowchart of a method for online duration statistics provided in an embodiment of the present application. The specific process of this embodiment is explained in detail below. The method for online duration statistics is applied to a system including a client and a server, wherein the client and the server are in communication connection. The method includes steps 100, 120, 140, and 160.
[0038] Step 100: The server detects the user's login to the client and creates a database to store the time the user logged in to the server and the local time the user logged in to the client. The local time the user logged in to the client includes the time the user first logged in to the client.
[0039] Step 120: Upon detecting a user's online time viewing operation, the server calls the online time interface and transmits the user's server login time, the user's client local login time, and the time the user called the online time interface server to the client, so that the client calculates the online time according to a preset statistical time model. The time the user called the online time interface server includes the time the user first called the online time interface server.
[0040] Step 140: The client obtains from the server the time when the user logs in to the server, the local time when the user logs in to the client, the time when the user first calls the online duration interface server, and the local time when the user first logs in to the client;
[0041] Step 160: The client substitutes the user login server time, the user login client local time, the user first call online duration interface server time, and the user first login client local time into the preset statistical duration model to calculate and obtain the online duration.
[0042] Exemplarily, the system architecture may include a server and multiple clients, each of which is in communication with the server. The multiple clients may be any terminal device, such as a mobile phone, laptop, computer, personal digital assistant (PDA), or in-car computer. The operating system of the terminal device may be a Windows operating system, a Unix-like operating system, a Linux-like operating system, a Mac operating system, or the like, which can be used to process and respond to client operations such as logging in and viewing online time. The server may be a server hardware system that records each client's login status, logout status, and online time interface call status, and stores these statistics in an event log table. The server hardware system may be run and executed at the software level by any of the aforementioned operating systems. In the event log table, all events may be arranged in chronological order according to the corresponding time periods of user login status, logout status, and online time interface call status. The server may select clients within a target time period for monitoring to calculate actual online time. The preset statistical duration model can be a mathematical statistical model for calculating online duration, using real-time variables such as login status, logout status, and online duration interface call status recorded during the interaction between the server and the client. For example, the model can be calculated by taking the difference between the client local time when the user logs in and the server system time when the user logs in, and summing the difference between the server system time when the user first calls the interface and the client local time when the user first logs in. The client local time when a user first logs in can be considered to be the client local time recorded at this time, as the next login is considered the first login only if the logged-in user has already logged out. Similarly, the server time when a user first calls an interface can be considered to be the server system time recorded at this time, as the first login is considered the first call only if the logged-in user logs in the next time after logging out or if the user first logs in.
[0043] When each client user logs into a target application, they send a login request to the server. Once the client confirms the login authorization, a login confirmation message is sent back to the client, allowing the client to log into the target application. When the client clicks the online duration button to view online time or logs out of the target application, since clicking the online duration button to view online time initiates a request to call the Web service interface, the server will also receive notifications of the online time interface call status and logout status. The target applications can include various applications such as games, music, video entertainment, learning, and social networking.
[0044] like Figure 2As shown, when a user logs in to a target application on the client, the server records the local time loginTime when the user logs in to the client, and the server system time at the time of login (the time the user logs in to the server); when the user checks the online time, a Web service interface is called, which transmits the local time loginTime when the user logs in to the client and the server system time systemTime when the interface is called to the client for use by the client; after the client obtains the local time loginTime of the user logs in to the client returned by the server, it combines the server system time at the time of login and the server system time systemTime when the interface is called, and calculates the user's online time according to a preset statistical time model (statistical formula), and then uses the calculated result as the actual online time.
[0045] Through this online duration statistics method applied to both the client and the server, a preset statistical duration model is set based on four times, namely, the client local time when the user logs in, the server system time when the user logs in, the server system time when the user first calls the interface, and the client local time when the user first logs in, and finally the user's online duration is calculated; this method enables accurate user online duration to be obtained even when server resources are not frequently called; it enables accurate user online duration to be obtained even when the server time is inconsistent with the client time; it enables accurate online duration to be counted even when the user logs in to the server at different times or the user automatically modifies the server system time; it reduces the interaction between the client and the server, and improves the efficiency and accuracy of online duration statistics.
[0046] See also Figure 3 , Figure 3 The flowchart of a method for calculating online duration applied to a client provided in an embodiment of the present application is provided below. The specific process of this embodiment is explained in detail. The method is applied to a client, and the client is in communication with a server. The method may include: Step 141 and Step 142.
[0047] Step 141: Obtain from the server the time the user logged in to the server, the time the user logged in to the client locally, the time the user first called the online duration interface server, and the time the user first logged in to the client locally;
[0048] Step 142: Substitute the user login server time, the user login client local time, the user first call online duration interface server time, and the user first login client local time into the preset statistical duration model for calculation to obtain the online duration.
[0049] For example, online duration can be calculated from the time the user logs in to the time the online duration is currently being viewed. The preset statistical duration model can be a mathematical statistical model for calculating online duration, using real-time variables such as the time the user logs in to the server, the time the user logs in to the client, the time the user first calls the online duration interface server, and the time the user first logs in to the client. The time the user first logs in to the client local can be the local time recorded at the next login, from among multiple local client login times stored on the server, if the logged-in user has logged out. The time the user first calls the interface server can be the server system time recorded at the first login, from among multiple server times for calling the online duration interface, if the logged-in user logs in next or for the first time, if the logged-in user has logged out.
[0050] When a user logs in to the controller from the server, both the user's server system login time and the client's local time are recorded and stored in the database. After logging in, when the user wants to check their online time, both the login time and the current system time are returned to the front-end for processing. The client calls the interface and uses a preset statistical duration model to calculate the user's online time. Specifically, the local time of the client login is subtracted from the server system time. The result is then added to the result of the first server login time returned by the server and the local time of the client's first call to this interface. The final result is the user's online time.
[0051] By using the online duration statistics method applied to the client, the client only needs to connect to the server once to obtain accurate online duration. Even if the user automatically modifies the server system time, accurate online duration can still be obtained. Even if the client time used by the user is different, the obtained user online duration is also accurate. There is no need to frequently call the interface to obtain time, which reduces the interaction between the client and the server and improves the efficiency and accuracy of online duration statistics.
[0052] In one embodiment, after step 142 , the method further includes: step 143 .
[0053] Step 143: The online duration is returned to the server side through the called online duration interface for display.
[0054] Exemplarily, the online duration interface can be an API (application programmable) interface, such as a web interface, which is called by the server to obtain relevant data when detecting a user's viewing operation on the online duration on the client side. When a request for displaying an online duration page is displayed, resources returned by the server are displayed, which include HTML, CSS and JS. In addition, the server can also return resources of types such as pictures, videos, fonts and plug-ins, which are all transmitted by the HTTP protocol. The HTTP protocol is a transmission protocol for transferring hypertext from a www server to a local browser. HTTP is based on the TCP / IP communication protocol to transmit relevant time data, and the HTTP protocol works on a client-server architecture, in which the browser acts as a client to send a request to the http server (i.e., the web server) through a url. Therefore, as shown in Figure 2 the online duration web interface can be called to transmit the online duration data calculated on the client side to the server side through the HTTP protocol for display, and finally the processed data is displayed on the display interface requested by the web interface, and the time will gradually increase with the user login time. By calling the online duration interface to return data for display, the user experience is improved.
[0055] In one embodiment, the preset statistical duration model includes: the online duration is equal to the sum of the first difference and the second difference; wherein the first difference is the difference between the user login local time and the user login server time; and the second difference is the difference between the user's first time to call the online duration interface server time and the user's first time to login the client local time.
[0056] Exemplarily, the preset statistical duration model can be a mathematical statistical model for calculating the online duration according to the above four times as variables. Specifically, it can be the difference between the client local time when the user logs in and the server system time when the user logs in, and the difference between the server system time when the user first calls the interface and the client local time when the user first logs in. The expression can be represented as: online duration = ((client local time when the user logs in - server time when the user logs in) + (server time when the user first calls the interface - client local time when the user first logs in)). Wherein, the client local time when the user logs in is a dynamic value, and refers to the local time at the moment of login, which changes with the change of the client local time; when calculating the online duration of the current login of a certain user, the first two terms of the formula are dynamic values, and the last two terms are fixed values, i.e., the server time when the user first calls the interface and the client local time when the user first logs in are fixed values.
[0057] By summing the difference between the client local time when the user logs in and the server system time when the user logs in, and the difference between the server system time when the user first calls the interface and the client local time when the user first logs in, the user's online time is finally calculated as the preset statistical time model. This eliminates the need to frequently call the interface to obtain time, reduces the interaction between the client and the server, and improves the efficiency and accuracy of online time statistics.
[0058] In one embodiment, step 140 further includes steps 144 and 145 .
[0059] Step 144: Obtain the increment time of the preset timer;
[0060] Step 145: Accumulate and update the online duration according to the added time.
[0061] In one embodiment, the server may be pre-installed with a timer plug-in, which can send a time reminder to the server. After receiving the time reminder, the server will store the user's online time and the timer time obtained by the last request in the database persistently to avoid data loss in the event of an unexpected termination of the server. Figure 2 As shown, the timer sends a reminder to the server at regular intervals. This reminder includes the time added after the client completes the online duration calculation based on the preset statistical duration model. This is equivalent to the client processing the four types of time data above and then using another timer to add 1 to the calculated online duration every second. When the time reaches 60 seconds, the time increments to 1 minute, when the time reaches 60 minutes, the time increments to 1 hour, when the time reaches 24 hours, the time increments to 1 day, and so on.
[0062] By adding a preset timer to accumulate and update the online time, it can prevent users from modifying the local time or server system time after logging in, which would lead to inaccurate final results. It can also avoid data loss in the event of an unexpected server termination, thereby improving the efficiency and accuracy of online time statistics.
[0063] In one embodiment, step 145 further includes steps 146 and 147 .
[0064] Step 146: Determine whether the time when the user logs into the server is consistent with the local time when the user logs into the client;
[0065] Step 147: If the user login server time is inconsistent with the user login client local time, the user login server time calculated by the preset statistical duration model is determined as the user login server time before the inconsistency to calibrate the online duration.
[0066] For example, when the server system time or the client local time is manually modified, the client local time will be inconsistent with the server system time. At this time, for example, the client local time is 10:00 and the server system time is 11:00. If the time does not need to be calibrated, it may happen that the user has just logged into the server and the user's online time is negative, or the online time has been several hours or days. That is, the statistical online time of the user will have errors, so time calibration is required.
[0067] The calibration method can be to substitute the pre-modified server system time or client local time into the preset statistical duration model to calculate online time. After the timer is updated, there is no need to use the modified server system time or client local time for subsequent online time calculations. For example, the calibration process can be: suppose the client local time at the time of user login is 10:00, and the server system time at the time of user login is 11:00. If the two are inconsistent, and the system time when the user first calls the user online time interface is 12:00, then the preset statistical duration model will calculate: ((10-11)+(12-10))=1. At this point, it can be seen that the user's online time has already been 1 hour, which is obviously inaccurate. Therefore, only the pre-modified server system time or client local time data is substituted into the model to calculate online time, and then updated according to the timer, without repeating the calculation using the modified server time.
[0068] Time calibration can further verify the accuracy of online duration. The client only needs to connect to the server once to obtain the accurate online duration. The time can then be recalibrated by calling the interface to make the time more accurate without occupying server resources. This allows clients with different local times to log in and obtain accurate online duration, improving the efficiency and accuracy of online duration statistics.
[0069] See also Figure 4 , Figure 4 The flowchart of a method for online duration statistics applied to a server side is provided in an embodiment of the present application. The specific process of this embodiment is explained in detail below. The method is applied to the server side, and the server side is connected to the client side for communication. The method may include: step 101 and step 102.
[0070] Step 101: Detecting a user's login to a client, and when the user logs in to the client, creating a database to store the time the user logged in to the server and the time the user logged in to the client locally; wherein the time the user logged in to the client locally includes: the time the user first logged in to the client locally;
[0071] Step 102: When a user's viewing operation on the online duration is detected, the online duration interface is called and the user login server time, the user login client local time and the user calling the online duration interface server time are passed to the client, so that the client calculates the online duration according to a preset statistical duration model; wherein the user calling the online duration interface server time includes: the user calling the online duration interface server time for the first time.
[0072] Exemplarily, the local time when a user logs into the client for the first time can be: the local time recorded at the next login when the logged-in user has logged out, among the multiple local times of the user logging into the client stored on the server side; the time when a user calls the interface server for the first time can be: the server system time recorded at the first call to the interface when the logged-in user logs in for the next login or the first login after each logout, among the multiple server times of calling the online duration interface stored on the server side.
[0073] When a user logs in to a target application on a client for the first time, the server creates a database to store the login time (both the time the user logged in to the server and the time the user logged in to the client) for use in calculating the user's online time. When the user checks their online time, a web interface is called, which transmits the two times mentioned above, as well as the server system time at the time the user called the interface, to the client for use in calculating and validating the user's online time. The preset statistical time model can be expressed mathematically as: ((client local time at user login - system time at user login) + (server time when the user first called the interface - client local time at user first login)).
[0074] By using the online time statistics method applied to the server, the client only needs to connect to the server once to obtain accurate online time. Even if the user automatically changes the server system time, the accurate online time can be obtained. Even if the client time used by the user is different, the obtained user online time is also accurate. There is no need to frequently call the interface to obtain time, which reduces the interaction between the client and the server and improves the efficiency and accuracy of online time statistics.
[0075] See also Figure 5 , Figure 5 This is a module function diagram of an online duration statistics device applied to a client provided in an embodiment of the present application. The client is communicated with the server, and the device includes: an acquisition module 210 and a calculation statistics module 220.
[0076] The acquisition module 210 is used to obtain from the server the time when the user logs in to the server, the time when the user logs in to the client locally, the time when the user first calls the online duration interface server, and the time when the user first logs in to the client locally;
[0077] The calculation and statistics module 220 is used to substitute the user login server time, the user login client local time, the user's first call to the online duration interface server time, and the user's first login client local time into the preset statistical duration model to calculate and obtain the online duration.
[0078] Optionally, the statistics calculation module 220 may be used to:
[0079] The online duration interface is called to return the online duration to the server for display.
[0080] Optionally, the preset statistical duration model includes: the online duration is equal to the sum of the first difference and the second difference; wherein, the first difference is the difference between the local time when the user logs into the client and the time when the user logs into the server; the second difference is the difference between the time when the user first calls the online duration interface server and the time when the user first logs into the local client.
[0081] Optionally, the statistics calculation module 220 may be used to:
[0082] Get the increment time of the preset timer;
[0083] The online duration is cumulatively updated according to the added time.
[0084] Optionally, the statistics calculation module 220 may be used to:
[0085] Determine whether the time when the user logs in to the server is consistent with the local time when the user logs in to the client;
[0086] If the user login server time is inconsistent with the local time of the user login client, the user login server time calculated by the preset statistical duration model will be determined as the user login server time before the inconsistency to calibrate the online duration.
[0087] See also Figure 6 , Figure 6 This is a module function diagram of an online duration statistics device applied to a server side provided in an embodiment of the present application. The server side is communicatively connected with a client side. The device includes: a storage module 230 and a calling interface module 240.
[0088] The storage module 230 is used to create a database to store the time when the user logs in to the client and the time when the user logs in to the server. The time when the user logs in to the client includes the time when the user logs in to the client for the first time.
[0089] The calling interface module 240 is used to call the online duration interface when the user checks the online duration and pass the user login server time, the user login client local time, and the user calling the online duration interface server time to the client to calculate the online duration; wherein, the user calling the online duration interface server time includes: the user calling the online duration interface server time for the first time.
[0090] See also Figure 7 , Figure 7 3 is a block diagram of an electronic device. The electronic device 300 may include a memory 311, a storage controller 312, a processor 313, a peripheral interface 314, an input and output unit 315, and a display unit 316. It can be understood by those skilled in the art that Figure 7 The structure shown is only for illustration and does not limit the structure of the electronic device 300. For example, the electronic device 300 may further include Figure 7 More or fewer components than shown, or with Figure 7 Different configurations shown.
[0091] The aforementioned memory 311, storage controller 312, processor 313, peripheral interface 314, input / output unit 315, and display unit 316 are electrically connected to each other, either directly or indirectly, to enable data transmission or interaction. For example, these components may be electrically connected to each other via one or more communication buses or signal lines. The aforementioned processor 313 is used to execute the executable modules stored in the memory.
[0092] The memory 311 may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory 311 is used to store programs, and the processor 313 executes the programs after receiving an execution instruction. The method executed by the electronic device 300 defined by the process disclosed in any embodiment of the present application can be applied to the processor 313 or implemented by the processor 313.
[0093] The processor 313 may be an integrated circuit chip with signal processing capabilities. The processor 313 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or any conventional processor.
[0094] The peripheral interface 314 couples various input / output devices to the processor 313 and the memory 311. In some embodiments, the peripheral interface 314, the processor 313, and the memory controller 312 can be implemented in a single chip. In other embodiments, they can be implemented in separate chips.
[0095] The input and output unit 315 is used to provide input data to the user. The input and output unit 315 can be, but is not limited to, a mouse and a keyboard.
[0096] The display unit 316 provides an interactive interface (e.g., a user interface) between the electronic device 300 and the user for the user's reference. In this embodiment, the display unit 316 may be a liquid crystal display or a touch display. The liquid crystal display or touch display may display the process of the processor executing the program.
[0097] The electronic device 300 in this embodiment can be used to execute each step in each method provided in the embodiments of the present application.
[0098] In addition, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiment are executed.
[0099] The computer program product of the above method provided in the embodiment of the present application includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the steps in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0100] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is merely a logical function division. There may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces, indirect coupling or communication connection of devices or units, which may be electrical, mechanical or other forms. The functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0101] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0102] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.
[0103] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for online duration statistics, characterized in that: Applied to a client, the client is in communication connection with a server; the method comprises: Obtain from the server the time the user logged in to the server, the local time the user logged in to the client, the time the user first called the online duration interface server, and the local time the user first logged in to the client; Substituting the time when the user logs into the server, the time when the user logs into the client locally, the time when the user first calls the online duration interface server, and the time when the user first logs into the client locally into a preset statistical duration model for calculation to obtain the online duration; wherein the preset statistical duration model includes: the online duration is equal to the sum of a first difference and a second difference; wherein the first difference is the difference between the time when the user logs into the client locally and the time when the user logs into the server; the second difference is the difference between the time when the user first calls the online duration interface server and the time when the user first logs into the client locally; Obtaining an increment time of a preset timer; and accumulating and updating the online duration according to the increment time.
2. The method according to claim 1, characterized in that After obtaining the online duration, the method further comprises: substituting the user login server time, the user client login local time, the user first call online duration interface server time, and the user first login local time into a preset statistical duration model for calculation. The online duration is returned to the server side through the called online duration interface for display.
3. The method according to claim 1, characterized in that After accumulating and updating the online duration according to the increased time, the method further includes: Determine whether the time when the user logged in to the server is consistent with the local time when the user logged in to the client; If the user login server time is inconsistent with the local time of the user login client, the user login server time calculated by the preset statistical duration model will be determined as the user login server time before the inconsistency to calibrate the online duration.
4. A method for online duration statistics, characterized in that: Applied to a server side, the server side being in communication with a client side, the method comprises: Detecting a user's login to the client, and when the user logs in to the client, creating a database to store the time the user logged in to the server and the time the user logged in to the client locally; wherein the time the user logged in to the client locally includes: the time the user first logged in to the client locally; When a user's online time viewing operation is detected, the online time interface is called and the user login server time, the user client local login time, and the time when the user calls the online time interface server are transmitted to the client, so that the client calculates the online time according to a preset statistical time model; the preset timer increment time is transmitted to the client, and the result of the client accumulating and updating the online time according to the increment event is obtained; wherein the time when the user calls the online time interface server includes: the time when the user first calls the online time interface server; Among them, the preset statistical duration model includes: the online duration is equal to the sum of the first difference and the second difference; among them, the first difference is the difference between the local time when the user logs into the client and the time when the user logs into the server; the second difference is the difference between the time when the user first calls the online duration interface server and the time when the user first logs into the local client.
5. A method for online duration statistics, characterized in that: Applied to a system including a client and a server, wherein the client and the server are in communication connection, the method includes: The server detects the user's login to the client and creates a database to store the user's login time and the user's client login time when the user logs in to the client; wherein the user's client login time includes: the user's first login time to the client; When the server detects a user's operation to view the online duration, the server calls the online duration interface and transmits the user's login time to the server, the user's local login time to the client, and the time the user called the online duration interface server to the client, so that the client calculates the online duration according to a preset statistical duration model; wherein the time the user called the online duration interface server includes the time when the user first called the online duration interface server; The client obtains from the server the time when the user logs in to the server, the local time when the user logs in to the client, the time when the user first calls the online duration interface server, and the local time when the user first logs in to the client; The client substitutes the user login server time, the user login client local time, the user first call online duration interface server time, and the user first login client local time into a preset statistical duration model for calculation to obtain the online duration; and obtains the increment time of a preset timer; and cumulatively updates the online duration according to the increment time; wherein, the preset statistical duration model includes: the online duration is equal to the sum of a first difference and a second difference; wherein, the first difference is the difference between the user login client local time and the user login server time; the second difference is the difference between the user first call online duration interface server time and the user first login client local time.
6. An online duration statistics device, characterized in that: Applied to a client, the client is connected to a server for communication, and the device includes: The acquisition module is used to obtain the user login server time, the user login client local time, the user's first call to the online duration interface server time, and the user's first login client local time from the server side; A calculation and statistics module is used to substitute the user login server time, the user login client local time, the user first call online duration interface server time, and the user first login client local time into a preset statistical duration model for calculation to obtain the online duration; and obtain the increment time of a preset timer; according to the increment time, cumulatively update the online duration; wherein, the preset statistical duration model includes: the online duration is equal to the sum of a first difference and a second difference; wherein, the first difference is the difference between the user login client local time and the user login server time; the second difference is the difference between the user first call online duration interface server time and the user first login client local time.
7. An online duration statistics device, characterized in that: Applied to a server side, the server side is connected to a client side for communication, and the device includes: The storage module is used to create a database to store the time when the user logs in to the server and the local time when the user logs in to the client; wherein the local time when the user logs in to the client includes: the local time when the user logs in to the client for the first time; The calling interface module is used to call the online time interface when the user checks the online time and pass the user login server time, the user login client local time, and the user calling the online time interface server time to the client to calculate the online time; wherein, the user calling the online time interface server time includes: the user calling the online time interface server time for the first time; and obtaining the increase time of the preset timer; according to the increase time, the online time is accumulated and updated; wherein, the preset statistical time model includes: the online time is equal to the sum of the first difference and the second difference; wherein, the first difference is the difference between the user login client local time and the user login server time; the second difference is the difference between the user calling the online time interface server time for the first time and the user logging into the client local time for the first time.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 2 are executed.
Citation Information
Patent Citations
Terminal program timing method and terminal program timing device
CN101621384A