Server-Side Row Model - paginationAutoPageSize don`t working for parent rows - ag-grid-angular

I am using ag-grid-angular 27.1.1
serverSideStoreType = 'partial'
If i setup paginationAutoPageSize = true and didnt provide paginationPageSize, when the getRows event performed the paginationPageSize is using default value 100 and pagination works only for 100 rows. If i setup paginationAutoPageSize = true and paginationPageSize = 10 the getRows event performed twice on gridReady event and then on every pagination event. If i setup paginationPageSize = 10 works fine but i cant change page size..
How i can implement paginationAutoPageSize or changing page size manually?

Related

MySQL - Track user activity to display content only the first time

I need to show a modal window the first time the user logs in, after logging in, that modal window should not be displayed.
Questions:
I'm thinking of creating a field in the user table to be called, modal_first_time, and adding the values 0 or 1
0 = Modal not shown
1 = Modal shown
So that when you log in for the first time, perform a logging in that table and change the value from 0 to 1, so you do not show that modal window again.
But is this optimal? What if I have 10 modal windows, do I have to create 10 additional fields?
It is well the way to add a field in the table, or there is some more optimal and simple, the best would be a session variable but these when clearing Cookies or switching computers would show again.
I would suggest making a "Modal accessed" table.
This table would hold 4 columns.
UID, UserID, ModalID, accessed
To find if the current status of a Modal for a user you would run a SELECT in your "onLogin" event.
Below is a very rough example of how this could be utilized to work for 1 or many Modals
SELECT ModalID FROM `SchemaName`.`ModalAccessedTable`
WHERE UserID = "Bob"
AND Accessed = 0
OR another usage
SELECT Accessed FROM `SchemaName`.`ModalAccessedTable`
WHERE UserID = "Bob"
AND ModalID = 'ModalName'
Update access usage
UPDATE `SchemaName`.`ModalAccessedTable`
SET Accessed = 1
WHERE UserID = "Bob"
AND ModalID = 'ModalName'
With a setup like this you can select, and update each individual entry per userID as needed, with relatively efficient lookup efficiency.
Side Note:
Assuming this table will become large, you will benefit greatly from properly build multi-column indexes.

sikuli how to check multiple images at the same time

Sikuli
I need to check if a specific region that exists images I want to click, and images will show up randomly, I write the code to check that, however it takes over 10 seconds to check the region, is there anyway I can shorten the time.
Settings.MinSimilarity = 0.95
Reg = Region(582,404,214,187)
img = capture(Reg)
search = True
Settings.MoveMouseDelay = 0
while search :
if Reg.exists("12.png") or Reg.exists("13.png") or Reg.exists("14.png")or Reg.exists("15.png")or Reg.exists("28.png"):
click(Reg.getLastMatch())
search = False
You can add a 0 parameter to the exists() call.
So instead of
if Reg.exists("12.png") or Reg.exists("13.png") or Reg.exists("14.png")or Reg.exists("15.png")or Reg.exists("28.png"):
You would have:
if Reg.exists("12.png",0) or Reg.exists("13.png",0) or Reg.exists("14.png",0)or Reg.exists("15.png",0)or Reg.exists("28.png",0):
According to this, the zero parameter means that
0 as the second parameter to exists forces, that only one search is executed and the result returned immediately. It does not wait the standard 3 seconds, so it is very responsive.
The smaller the region, the faster this will be.
Try this:
Reg.setAutoWaitTimeout(0.5)
This reduce time for detection from 3 secs to 0.5 secs or the value you like.

ActiveRecord model column not updating (even though save! succeeds)

I've got a really, really odd problem manifesting on a big Rails e-commerce app and thought I'd see if anyone has good insight. I have an"Order" model with many associations. If I create a new instance, and then set one particular column value and "save!" the "save!" is succeeding without errors, but the change isn't actually persisted to the DB. I'll run through the scenario below:
#order = Order.create!(<some attributes>)
=> true
#order.shipping_method_id
=> 1
#order.shipping_method_id = 203
=> 203
#order.save!
=> true
#order.shipping_method_id
=> 1
To try and debug this I actually prepended a before_save filter and I can see that when this first filter is called after setting the value, it is correct ("203") BUT the very next before_save after the 6-or-so built-in "autosave_foo_bar_quux" filters (for nested associations) it is back to "1".
Oddly, if I just reload the order (#order.reload), change the column value and save! the update does succeed.
In both cases, doing #order.changed shows that ActiveModel recognizes the column value change for shipping_method_id. In the first, though, the SQL logging shows that the order row is not updated.
I feel like I'm going insane. Any ideas? Also, let me know if there's anything else I can post here for more context.

Check if mySQL record added in the last x seconds

I have a mySQL database and a table where new records for a project are created. Each project created has a "project name" and an event created date (of type DATETIME).
There can be two projects created with the same name, but if they get created by the same user in quick succession, it is safe to assume it was a mistake on the user's part (clicking twice, refreshing the browser when event variables are passed, etc.).
How do I write a SQL statement to check if a record with the same name already exists, it was added in the last 10 seconds? So far I have the following, although I don't know how to check for the last 10 seconds.
select * from projects where user = 'johnsmith' AND projectname = 'test' AND active='y' AND DATE(projectcreatedon) = CURRENT_DATE AND DATEPART() < ....?
replace AND DATE(projectcreatedon) = CURRENT_DATE AND DATEPART() < ....? with:
AND projectcreatedon > (now() - INTERVAL 10 SECOND)
I would suggest not to keep such checks in MySQL because that might not be the perfect way of knowing mistakes because the user might well click the submit or refresh the page after 10 seconds. Instead, put checks in the front-end code to disable clicking the submit button twice or redirect the user to a page where no variables are passed.
But if that isn't what you would like to do, then this might be your query:
SELECT *
FROM `projects`
WHERE `user` = 'johnsmith'
AND `projectname` = 'test'
AND `active`='y'
AND TIMESTAMPDIFF(SECOND, projectcreatedon, now()) > 10;
You're trying to fix the problem in the wrong way. Why not eliminate the problem at the source? Make it impossible for the user to create these two projects successively.
If your app makes it possible for a user to submit a form multiple times via refresh, consider using a redirect after the GET/POST variables have been processed.
Furthermore, use simple client-side tricks to disable the submit button after it has been clicked once. You can accomplish this with a very small amount of jQuery

ActiveRecord caching and update_attributes

If a model changes an attribute locally, then changes it back, ActiveRecord doesn't send the change to the DB. This is great for performance, but if something else changes the database, and I want to revert it to the original value, the change doesn't take:
model = Model.find(1)
model.update_attribute(:a, 1) # start it off at 1
# some code here that changes model.a to 2
model.a = 2 # I know it changed, reflecting my local model of the change
model.update_attribute(:a, 1) # try change it back, DOESN'T WORK
The last line doesn't work because AR thinks in the DB it's still 1, even though something else changed it to 2. How can I force an AR update, or update the cache directly if I know the new value?
Side note: the code that changes it is an update_all query that locks the record, but it has side effects that mess up the cache. Multiple machines read this table. If there's a better way to do this I'd love to know.
Model.update_all(["locked_by = ?", lock_name], ["id = ? AND locked_by IS NULL", id])
Use the reload method for this.
model.reload(:select => "a")
OR
You can try the will_change! method(Its not clear how your change happens. But you can try this method).
model.update_attribute(:a, 1) # start it off at 1
model.a_will_change! #fore warn the model about the change
model.a = 2 #perform the change
model.update_attribute(:a, 1)
The answer by Harish Shetty is correct, you need to call reload on the reference, however I found a better way to do that automatically.
In your model you want to reload attribute to, create a after_update callback and call reload directly there, like so:
after_update :reload_attr
def reload_attr
reload select: "attr"
end