Rails 3 Saving User Searches DataModel - ruby-on-rails-3

I am working on a piece of my app where the client is wanting the ability for user searches to be saved (these searches are completed by the user completing a set of dropdowns and then entering in a value in an input field).
I was curious to know if the use for an HSTORE could be beneficial here or should I just simply save out each piece of the search?
For Example (from a UI perspective):
User Selects a category, the next select is populated with stats tied to the selected category, the next select drop down is displayed which allows the user to select a predicate (greater than, less than, equal to, not equal to, etc) and then the input field is shown where the user can enter in their value they are searching for. If the user would like to add another search filter, they can click a button and then the user follows the same pattern as the first
The server side params look like this:
Parameters: {"utf8"=>"✓","authenticity_token"=>"FCvOdXuxtEhEchwDn8U2yaEPShfHW2VosgSoR8eSzV8=", "refresh"=>"1", "search"=>{"0"=>{"category"=>"1", "stat_type_id"=>"5", "predicate"=>"Greater Than", "q"=>"200", "type"=>"stat"}}, "unselected"=>""}
These searches won't really be updated, when a user enters in a new search, it will be saved explicitly.
Once we figure out the best route for this project, I will post the code as the answer

Related

Providing alternative search data to Datatables JS

We have a table that contains a user's email address, their first name and last name and some date columns. The standard search works great for those.
I would like to provide a way of the user being searchable by their user id which is a GUID. The user id is not a visible piece of data. This search would really only be used by admins
I know I could use the data-search attribute on the user name column e.g.
data-search="43b30438-e3c8-4e27-8b31-5fcc52e53a3b me#test.com"
However that makes that row and any other row findable with just the number "43" as that GUID starts with 43 or "52" because it has a 5 followed by an 2. That is clearly not what I want. How do I make the users searchable by their GUID as well as their username but in the case of the GUID only when it is the whole GUID being searched for?
Thanks

Access 2010 VBA and filtering

Good Day,
I need some assistance please. I am rebuilding a third party Access database after it's catastrophic failure and the failure of the 3rd party developer to fix his mess. I am an avid Access Developer and know my way around an Access Database well. I am not a super VBA coder, but I can do more than my bit in VBA as well as a few other languages.
Currently, I have a database test bed with a login form that stores 3 values as public variables (gstrLevel as String, gstrUser as String, gintID as Integer). I am able to set my own "permissions" with ease in that once they login I can use the values to control the switchboard etc.
My problem now is the following. We have people recording prospective client interactions and interviews. As part of the process, every time they make contact, they record this into the database and in the process a "followup date" is created. This works like a charm. What I now need to do is warm the users if these followup dates are close or have passed so that prompt action can be taken lest we lose a prospective client.
I have a query that takes the prospective table information, and the notes table information (where the followup date is stored) and then filters the dates correctly. This in turn has been used to create a continues form to display the records that need followup soon. What I cannot seem to do is to get it to only show the logged in users followup records.
I should note that the user/agent field is a lookup field in the prospective table, and thus also creates a combo box in the Followup form. I can lock the form from changes etc, but I can't seem to get it to only display the relevant user/agent details.
I have tried:
DoCmd.ApplyFilter
Me.Filter
Me.FilterOn = True
DLookup as criteria
Using my public variables directly as query criteria
And a few other weird combinations with no success.
My problem, I believe, is the fact that the user/agent is a lookup field, and I am not sure how to filter based on that fact. If I use the gstrUser variable directly I get a type mismatch and if I use gintID directly it shows nothing.
Any ideas or advice would be greatly appreciated.
You probably have a Users table, with a numeric Primary Key (PK), while your gstrUser stores the userName.
So in the source of your Followup form, just add the Users table (joined to the Prospective table on UserId) and apply the filter on the userName field in the Users table (or whatever it's called that matches the contents of gstrUser).

Set value dynamic action not working in apex

I have a problem creating sql dynamic action in oracle apex v4.2. I have two fields, Department number and department name. Department number is a text field with autocomplete. The department name is a display field. On changing the department number, the department name should be displayed by an sql query.
I created a set value dynamic action on department number, giving the correct values in page item to submit and the correct sql query referencing P3_DEPARTMENT_NO.
When i run the page, after select a department number, the department name is not coming up automatically.
Could you please suggest on what i might be missing.
Thanks in advance.
You can try use this way:
First step: In the Shared Components -> Application Processes: create a process myProcess an put your sql dynamic in.
Second step: Create a javascript function myFunction to call the process myProcess.
Third step: Use onChange event to call your javascript function myFunction.
Also you can find a lot of exemples on Denes Kubicek app: https://apex.oracle.com/pls/otn/f?p=31517:101:116042570427567.
Best regards,
iulian
The exact behaviour of autocomplete lists is probably browser dependent, but generally speaking, don't rely on the "Change" event, as it won't necessarily fire when you select from the list.
You'll need to experiment to get the behaviour you want in your particular situation, but as a starting point you might want to try replacing the "Change" event type on your dynamic action with "Lose focus". That way the dynamic action should always be triggered when you tab or click away from P3_DEPARTMENT_NO.
In similar situations in the past, I've used "Key release" instead of "Lose focus", and I've created a second dynamic action which does the same thing, but triggered by "Get focus". That combination ensures that the display field stays synchronised with the user's selection, whether a value is keyed in or selected from the autocomplete list. Whether or not you go this route depends on how happy you are about the database being hit with your department name query every time a user interacts with P3_DEPARTMENT_NO in any way.

MS Access 2007 - Select multiple records and assign a value into a field

I am using a Multiple Items Form to list CASES (records) where there is no TECHNICIAN assigned (Maybe I should use a Datasheet to list the records?).
I would like the user to select a TECHNICIAN from a dropdown field that gets its values from an Employee Table (I can do this). Then I would like the user to select multiple CASES (records) in order to assign that one TECHNICIAN to the Technician field in all of the selected CASES.
Basically, I'm trying to keep the user from having to assign a technician from within each and every incoming case request. I want them to "batch" assign a tech to multiple cases.
Can someone point me in the right direction?
Ok so I did some more research. This may not be the best answer but it works for now.
I created a Multiple Item Form.
I added an unbound dropbox that lists Employees from the table
I added a button on the detail section (for each record) with the follow line of code:
Me.Technician = Me.Choose_Technician
Now the user can pick a technician from the dropdown and then click the button to assign that technician to the record/casefile.
This is a simple solution if you only have a couple of records/casefiles to assign. If the amount of incoming casefiles increases there will have to be a way to select multiple records using the shift key. I'll keep researching this.

MySQL joins for friend feed

I'm currently logging all actions of users and want to display their actions for the people following them to see - kind of like Facebook does it for friends.
I'm logging all these actions in a table with the following structure:
id - PK
userid - id of the user whose action gets logged
actiondate - when the action happened
actiontypeid - id of the type of action (actiontypes stored in a different table - i.e. following other users, writing on people's profiles, creating new content, commenting on existing content, etc.)
objectid - id of the object they just created (i.e. comment id)
onobjectid - id of the object they did the action to (i.e. id of the content that they commented on)
Now the problem is there are several types of actions that get logged (actiontypeid).
What would be the best way of retrieving the data to display to the user?
The easiest way out would be gabbing the people the user follows dataset and then just go from there and grab all other info from the other tables (i.e. the names of the users the people you're following just started following, names of the user profiles they wrote on, etc.). This however would create a a huge amount of small queries and trips to the database in a while loop. Not a good idea.
I could use joins to retrieve everything in one massive data set, but how would I know where to grab the data from in just one query? - there's different types of actions that require me to look into several different tables to retrieve data, based on the actiontypeid...
i.e. To get User X is now following User Y I'd have to get my data (User Y's username) from the followers table, whereas User X commented on content Y would need me to look in the content table to get the content's title and URL.
Any tips are welcome, thanks!
Consider creating several views for different actiontypeids. Union them to have one full history.