foggy
foggy
KPCKevin Powell - Community
Created by foggy on 1/5/2024 in #back-end
App statistic recording strategies
Hi gang, I'm building an app that does 'stuff'. Things in the app can be on or off. I need to create historical graphs of the totals of 'on' things over time. Simple enough. The app is built with Laravel (PHP/MySQL). My strategy at the moment is to have a daily runner script that selects the count of rows in the tables I'm interested in where status=1 (1 being 'on'). That yields an integer which I dump in a stats table along with the current date. That stats table is then harvested for relevant data the results being passed to the graphing system (Apex) in the main app and a simple datetime graph is produced. All that works. My issue is that the graph has a potential 24 hour latency before it's updated with correct figures. 24 hours could elapse with the graph being potentially incorrect. How is this dealt with in 'real' apps'? As I see it, I could: 1/ Put a disclaimer on the graph saying they're updated daily at midnight. Provide the accurate number on-demand in a small panel keeping the historicals separate. 2/ Increase the frequency of the runner. This would increase the granularity of the graph but greatly increase the rows in (and load on) the database (the example I gave above is a simplified example of what I'm actually doing - there's potentially hundreds of these counters). As time rolls on, the volumes of data being lobbed about will increase exponentially. 3/ Implement some sort of RRD wizardry. Still potentially heavy on the recording side also granularity is lost over time. 4/ Something else I'm not aware of or thinking of? 5/ I've just had a thought - A bunch of the systems I use at work all have up-to-the-minute accurate graphs of the stuff they're report on. How do they do that? Do they do what I'm doing already but tack on a quick point-in-time count before the graph is displayed? That might be the way.. Well, I'll post this anyway - always keen to learn! cheers! e
23 replies
KPCKevin Powell - Community
Created by foggy on 6/1/2023 in #back-end
POST contents of a listbox
Hi! I have a dual listbox thing where the left and right is populated from a database. There's some buttons and a bit of JS that allows items to move left and right between the two. Basically copied this and added my own database logic: https://codepen.io/afrost/pen/EyQOxx My data/schema is pretty simple - id# and a name. What I want to do (ultimately) is insert the id's of the contents of the right listbox to a database. If I can get the id's into a variable/array, I'll be able to go from there. Does that make sense? Test code is below - I've had to trim it because of the 2000char limit but it should have the pertinent bits. I'll add the missing bits below if needed. The left list populates correctly and I can move items left and right as I wish. I want to extract the contents of the rightmost column on a 'submit'. cheers! <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <script> the JS from that URL. </script> <form action="/lists.php" method="POST"> <div class="approveTermsContainer"> <div class="newItems"> <b>Available organisations:</b><br/> <select multiple="multiple" id="lstBox1"> <?php foreach ($orgs as $row) { echo '<option value="'.$row["id"].'">'.$row["name"].'</option>'; } ?> </select> </div> <div class="transferBtns"> <input type='button' id='btnRight' value =' > '/> <br/><input type='button' id='btnLeft' value =' < '/> <div class="submitContainer"> <input type="submit" value = "submit"/> </div> </div> <div class="approvedItems"> <b>Selected Organisations: </b><br/> <select multiple="multiple" id="lstBox2" name="AdminOrgs"> </select> </div> </div> </form>
3 replies
KPCKevin Powell - Community
Created by foggy on 5/17/2023 in #back-end
PHP - What's going on here?
Hi.. Quite new to LAMPy stuff - I'm trying to pick apart a bit of code here. Can someone explain what's going on? I get what it's doing, I just can't put a name to the functionality to explore it further if that makes sense. php > unset ($error); php > echo (empty($error)) ? 'The string is empty' : 'The string has something in'; The string is empty php > $error = "Something"; php > echo (empty($error)) ? 'The string is empty' : 'The string has something in'; The string has something in php > Obviously the ? and : is doing some decision making based on a true/false from the empty($error) - is this part of 'echo' or something else? Googling "PHP echo ? :" doesn't yield much of interest 🙂 cheers!
8 replies