how to define models, validators, expiring URL, by using Following data? - django-rest-framework

id auto increment
Name : source name (unique) mk
Desc : small descripton to know about sourc
rooturl : domain Name that deployed this tinny url https://tm.py/
Active/Expired: Bool
Createdon
CreatedBy
Tinny URL tables
id, : auto
sourcecode : source table code mk
tinnycode : generated 6 digits code ( should be unique for source) A123h5
MainURL : actual url
tinnyURL: tinney https://tkm.py/A123h5
validity : no of days valid from created date
Createdon : auto
createdby : request by
RequestFrom : request header info ( Like IP,request url, user etc)
setTinnyURL( Source, actual URL, validity)
soruce :Mk
actual URL :
https://airbrake.io/blog/python/zerodivisionerror-2#:~:text=As%20you%20may%20suspect%2C%20the,or%20modulo)%20operation%20was%20zero.&text=We'll%20also%20see%20how,handling%20division%20by%20zero%20issues.
validity : 3
log ( "got tinney request for MK soruce", "IP",USr)
generate Tunney code 6 unique A123h5
{
status: 200
message": success
response:{
TinnyURL: "https://tkm.py/A123h5"
}
}
getTinnyURL(tinnyURL)
check tinnyurl in Tinny URL tables , value matched in tinnyURL field then retun actualURL

Related

Define more than one type of query GraphQL Schema - Best approach to define different types on query one one object

Is this possible to specify more than one type of query in one schema?
type Query {
productsByRegion(match : String) : [Product]
productsByType(match : String) : [Product]
}
type Product {
id: ID
name: String
}
Expected queries which can be fired using single schema definition:
{
productsByRegion {
id
name
}
}
{
productsByType {
id
name
}
}
GraphQL java implementation cached some data. After server, restart both the query works fine.

Apache NiFi put value to serial column

I have a database table with following structure:
CREATE TABLE fact.cabinet_account (
id serial NOT NULL,
account_name text NULL,
cabinet_id int4 NULL,
CONSTRAINT cabinet_account_account_name_key UNIQUE (account_name),
CONSTRAINT cabinet_account_pkey PRIMARY KEY (id),
CONSTRAINT cabinet_account_cabinet_id_fkey FOREIGN KEY (cabinet_id) REFERENCES fact.cabinet(id)
);
And I have a JSON from InvokeHttp which I want to put to database:
{
"login" : "some_maild#gmail.com",
"priority_level" : 5,
"is_archive" : false
}
I'm using QueryRecord with this script:
SELECT
19 AS cabinet_id,
login AS account_name
FROM FLOWFILE
I'm trying to UPSERT in PutDatabaseRecord processor and got the error:
ERROR: value NULL at column "id"
How to put value for serial column with Apache NiFi?
UPDATE
My JSON looks like (before PutDatabase):
[ {
"account_name" : "email1#maximagroup.ru",
"priority_level" : 1000,
"cabinet_id" : 19
}, {
"account_name" : "email2#gmail.com",
"priority_level" : 1,
"cabinet_id" : 19
}, {
"account_name" : "email3#umww.com",
"priority_level" : 1000,
"cabinet_id" : 19
} ]
PutDatabaseRecord looks like:
Try making the operation INSERT rather than UPSERT
An UPSERT needs to check whether the given id exists, to know if it should insert or update, which it can't do as no id is provided.

How can we write mongo db query in Spring

I have a Feed collection that has two fields: username and sentiment. I have to write a aggregation in spring to group by username and sentiment. I also have to display total number of times username comes in collection.
How to do that?
My code is:
db.feed.aggregate([
{$group: {_id : {username : '$username',sentiment:'$sentiment'}, total:{$sum :1}}},
{$project : {username : '$_id.username', sentiment : '$_id.sentiment', total : '$total', _id : 0}}
])
The first thing that comes to mind:
http://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.aggregation
So in your case it would look something like:
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
class Stat {
String username;
String sentiment;
int total;
}
Aggregation agg = newAggregation(
group("username", "sentiment").count().as("total"),
project().
and("_id.username").as("username").
and("_id.sentiment").as("sentiment").
and("total").as("total")
);
AggregationResults<Stat> results = mongoTemplate.aggregate(agg, "feed", Stat.class);
List<Stat> mappedResult = results.getMappedResults();

How to validate a POST request for postUserAction

I get a problem with the validation of a new user request on my api.
I know there's a problem in my code but I cannot figure it out :
UserType
postUserAction
And I send via google Postman, this json :
{
"username":"Username",
"email":"example#mail.com",
"plainPassword":"SecretPassword",
"lastname":"Smith",
"firstname":"John",
"job_position":"CEO",
"phone":"+666133742",
"company_name":"Microtosh",
"website":"www.omgthatsaflippingspider.com",
"sector":"Food & Stuff",
"address":"12 st Overkill",
"city":"SinCity",
"zip_code":"W4224",
"country":"US",
"billing_infos_same_as_company":true,
"putf":"1",
"das":"Manchester United"
}
Now I seems to validate but I get an error :
Column 'password' cannot be null
When I look up the $form -- before $userManager->updateUser($user) -- I get this :
plainPassword:
{
-children:
{
-first:
{
-errors:
[
"fos_user.password.mismatch"
]
}
second: [ ]
}
}
Now first, why does it validate since it didn't find a match between password and confirmation ?
And am I doing the right thing, with the creation of a new user ? I don't understand what I am missing.
Just change the form type of password field to password instead of repeated and it should work ;)

Invalid Resource Id when batch inserting

I am doing a batch insert into the Google Calendar using the .NET API. I have the following code.
var request = new BatchRequest(calendarService);
request.Queue<Event>(
calendarService.Events.Insert(
new Event
{
Id = String.Format("yot-{0}", item.AppointmentId),
Summary = item.Title,
Description = item.Description,
Start = new EventDateTime() { DateTime = item.Date },
End = new EventDateTime() { DateTime = item.Date.AddHours(item.Length) }
}, calendar.Id),
(content, error, i, message) =>
{
//Log error
});
request.ExecuteAsync();
When I execute and try and insert I get the error "Invalid resource id". What does this error mean?
You have to follow the guidelines defined here : https://developers.google.com/google-apps/calendar/v3/reference/events/insert
Basically, the id has to be between 5 and 1024 characters long and consist solely from characters in this alphabet : 0123456789abcdefghijklmnopqrstuv.
Try with a simple Guid.NewGuid() or use a Base32 Encoder if you don't want random IDs

Resources