How to retrieve group notification_key or delete existing group? - google-cloud-messaging

Documentation is very poor concerning anything but the basic example and I cannot find how to retreive group notification_key or, alternatevly, delete a group using its notification_key_name and then create it again so that I could store its notification_key.
The reason I need this is that I forgot to store the notification_key the first time I created a group for a notification_key_name, for which I used a combination of app name and username. When I try to create a group with the same notification_key_name, I get a response that group already exists. I could probably change the key_name into something else (and in retrospect I should have used something like test-johndoe while testing), but it would be much better to somehow retreive the group key or just delete the entire group and create it again. How do I do that?

Related

Does the Google Ads ad_group_ad has an unique atribute?

I'm writing a code to load data from Google Ads api to BigQuery table by using Cloud Functions, the process query a table called ad_group_ad but i'm struggling when trying to validate if there's duplicated rows at my destination.
By reading the docs I was expecting to find some attribute used to identifier a column or a group of columns that represents the table key. May this question seem obviously but i ain't having progress when trying to google this.
Is there a way to identifies if there's is duplicated rows? I'm not using any group by instruction when collecting, just a simple select like the example below:
SELECT
segments.ad_network_type,
campaign.name,
ad_group.name,
ad_group.id,
so
on,
and,
so,
forth
FROM ad_group_ad
WHERE segments.date = ?
The combination of ad ID and ad group ID is guaranteed to be unique.
However, as soon as you include segments in your select clause, you'll get multiple rows with the same IDs. So the combination of ad_group.id, ad.id plus whatever segment fields you need should be a candidate key.

Messages read by groups without own database table

I have this table used when a user writes a note.
When writing a note, the user specifies if a sell-department and/or a buy-department should receive the note.
Each user can create a Case (lets say its just a table with case_id and case_text). And the notes the users write are related to a case.
So the table NOTES is (postgres database) something like this:
ID
TEXT (the message itself)
USER_ID (the user that writes the note)
CASE_ID (the case_id for which the note is been written)
Short word about users:
There are "ordinary" users and those working on a department. This should not make big difference for the description here.
When an ordinary user writes a note, let's say he want both buy-department and sell-department to be included (being informed about the note/see the note).
What happens now is that there is another table called UserNotes. It looks like this:
ID
IS_READ
NOTE_ID
USER_ID
DEPARTMENT_ID
READ_AT_DATE
So ordinary user with id = 1 writes this note and in the code (as he tells sell and buy-departments have to be included) I search for all the users working at that specific sell-department and all those working at that specific buy-department. I then put all these users in the table UserNotes. With IS_READ false by default.
When a user in the specific sell-department reads the note, I will then change IS_READ for this user's entry in UserNotes.
This is how it works today. I don't think this is scalable. I'm already getting performance issues. I don't think it is important to know when a note has been read. So because of this I was thinking that maybe the following solution could work. Please have a look and tell me if it could be better and the current one or if you have some other suggestion please let me know:
I drop UserNotes table. I add a new filed in table Notes: READ_BY. Here I will update the field each time a user reads the note.
I don't know if I could use some postgres-specific thing, maybe making this field a json-string and searchable.

Group similar records by same ID in access

I have a table full of clients in access and some are similar to each other (eg. NBC6, NBC10, etc.) I was wondering if there was a way to group all the similar clients and assign them all 1 ID. They would all start off the same so I was thinking to search for them like that but I'm unsure how to go about this in VBA. I am rather new to access and SQL so any help would be greatly appreciated!
Create a new field in your table called ClientGroup. Set its datatype to Text.
Get a list of all ClientGroup names you want to use. Let's say, for example, that NBC6 and NBC10 should end up in one group called NBC.
Run an Update query to assign that group:
UPDATE tblClients
SET ClientGroup = "NBC"
WHERE ClientName LIKE "NBC*"
The asterisk sign acts as a wildcard, so it will only update the records where the first 3 letters of ClientName are "NBC".
It's a lot of manual work, I suppose if you know you always want to use just the first 3 characters of a ClientName you can write a loop to put them in an array, but that's probably not the case.

Selecting specific joined record from findAll() with a hasMany() include

(I tried posting this to the CFWheels Google Group (twice), but for some reason my message never appears. Is that list moderated?)
Here's my problem: I'm working on a social networking app in CF on Wheels, not too dissimilar from the one we're all familiar with in Chris Peters's awesome tutorials. In mine, though, I'm required to display the most recent status message in the user directory. I've got a User model with hasMany("statuses") and a Status model with belongsTo("user"). So here's the code I started with:
users = model("user").findAll(include="userprofile, statuses");
This of course returns one record for every status message in the statuses table. Massive overkill. So next I try:
users = model("user").findAll(include="userprofile, statuses", group="users.id");
Getting closer, but now we're getting the first status record for each user (the lowest status.id), when I want to select for the most recent status. I think in straight SQL I would use a subquery to reorder the statuses first, but that's not available to me in the Wheels ORM. So is there another clean way to achieve this, or will I have to drag a huge query result or object the statuses into my CFML and then filter them out while I loop?
You can grab the most recent status using a calculated property:
// models/User.cfc
function init() {
property(
name="mostRecentStatusMessage",
sql="SELECT message FROM statuses WHERE userid = users.id ORDER BY createdat DESC LIMIT 1,1"
);
}
Of course, the syntax of the SELECT statement will depend on your RDBMS, but that should get you started.
The downside is that you'll need to create a calculated property for each column that you need available in your query.
The other option is to create a method in your model and write custom SQL in <cfquery> tags. That way is perfectly valid as well.
I don't know your exact DB schema, but shouldn't your findAll() look more like something such as this:
statuses = model("status").findAll(include="userprofile(user)", where="userid = users.id");
That should get all statuses from a specific user...or is it that you need it for all users? I'm finding your question a little tricky to work out. What is it you're exactly trying to get returned?

Getting last inserted id from a table not part of the current controller I am in

I need to get the last inserted ID from a table which is not part of the current model nor the current database connection: right now I am in table (pdtlisting) but I want to get the last inserted id from table (deallisting). How can i get it?
try this..
Its for mySql..
LAST_INSERT_ID()
OR
Its for Php..
mysql_insert_id()
All the last_insert_id functions (be they PHP wrappers or the native mySQL one) typically refer to the last ID created using the current database connection. The last login was probably not created during the same request you are showing the table in, so this method won't work for you.
Use a normal SELECT to find out the newest login instead - e.g. by using ORDER by creationtime DESC LIMIT 1.
OR
In Yii you can find the last inserted id like this ..
Yii::app()->db->getLastInsertID();
also you can refer this link..
http://www.yiiframework.com/doc/api/1.0/CActiveRecord#primaryKey-detail