Workfront API - List of tasks modified after a specific datetime - workfront-api

Is it possible to get the list of tasks modified after a specific date time using the search API ?
Specifically, we are looking for all the auditnotes added after any specific time.

The auditNote is not a separate object so it won't have its own timestamp. You can search for the last update being after date D with a search on task?lastUpdateDate=D&lastUpdateDate_Mod=ge but it will look for any update perofrmed on the task, not just an auditnote update.
You could always search for all tasks modified after a given date (as above) and then iterate through the returned task IDs, each time searching for all notes whose objectID is the task's ID and filtering again for dates >= your audit date. You could also filter based on the audittype as listed below.
ST (Status Change)
AA (Attachment Action)
SC (Scope Change)
NO (Note)
GE (General Edit)
CM (Combined Entry)
ER (Error Entry

Related

How to auto increment document id in firestore based on the input number

Average use case of the app is a form being filled by a surveyor, I have to produce a unique id for every entry based on three drop down selections, shown in the image below:
I have to produce a unique Consumer-Id for every entry based on zone and ward selection, as an example, the surveyor selects zone 01, and ward 02, and enters the first entry, the consumer id should be 01-02-01 respectively, AND when change the selection of either the zone or ward, the entry number should start from 1, and if they switch back to the zone and ward where they had made some entries before, let's say in zone 01, ward 02 they made 25 entries, so the last consumer id was 01-02-25, when they switch back to this zone and ward the entry should continue from 26.
I am unable to devise a logic for the above requirement, is it possible to achieve in firestore or locally inside the app?
Assuming you have the fields zone and ward in your firestore documents, you can check how many entries have been made in that particular zone and ward by chaining two where clauses as shown below
Future<int> countEntriesInZoneWard(String zone, String ward) async {
final QuerySnapshot result = await FirebaseFirestore.instance
.collection('yourCollectionName')
.where('Zone', isEqualTo: zone)
.where("Ward", isEqualTo: ward)
.get();
final List<DocumentSnapshot> documents = result.docs;
return documents.length;
}
The above code will return the length of the documents, or in other words, will give you a number of entries with the specified zone and ward, in order to generate a number for the new id, receive this method's returned value in a variable and add 1 to get the current entry number for the new id as follows:
entryNum = await _db.countEntriesInZoneWard(zone, ward) + 1;
Now you can append this variable entryNum at the end of your string for the Consumer Id
These IDs that you're describing are known as sequences, because the ID of the next item depends on the previous item in the same sequence.
So, in order to determine the ID for the next item, you will either have to know the ID of the (so far) last item in the sequence. If all items are added by a single app instance/user, you can store the latest ID of each sequence in the local storage of the app. If items are added across devices/users, you will have to store the IDs in a database, such as Firestore, that all the devices can access.
With that, the sequence to add an item becomes:
Read the latest ID from the sequence.
Add the next item in the sequence.
Write the incremented latest ID and next item.
If you're using a shared stored mechanism such as Firestore for this, you'll have to use its transaction mechanism to prevent users from generating the same ID.

How do I create a running count of outcomes sequentially by date and unique to a specific person/ID?

I have a list of unique customers who have made transactions over a year (Jan – Dec). They have bought products using 3 different methods (card, cash, check). My goal is to build a multi-classification model to predict the method pf payment.
To do this I am engineering some Recency and Frequency features into my training data, but am having trouble with the following frequency count because the only way I know how to do it is in Excel using the Countifs and SUMIFs functions, which are inhibitingly slow. If someone can help and/or suggest another solution, it would be very much appreciated:
So I have a data set with 3 columns (Customer ID, Purchase Date, and Payment Type) that is sorted by Purchase Date then Customer ID. How do I then get a prior frequency count of payment type by date that does not include the count of the current row transaction or any future transactions that are > the Purchase Date. So basically I want to do a running count of each payment option, based on a unique Customer ID, and a date range that is < purchase date of that training row. In my head I see it as “crawling” backwards through the transactions and counting. Simplified screenshot of data frame is below with the 3 prior count columns I am looking to generate programmatically.
Screenshot
This gives you the answer as a list of CustomerID, PurchaseDate, PaymentMethod and prior counts
SELECT CustomerID, PurchaseDate, PaymentMethod,
(
select count(CustomerID) from History T
where
T.CustomerID=History.CustomerID
and T.PaymentMethod=History.PaymentMethod
and T.PurchaseDate<History.PurchaseDate
)
AS PriorCount
FROM History;
You can save this query and use it as the source for a crosstab query to get the columnar format you want
Some notes:
I assumed "History" as the source table name - you can change the query above to use the correct source
To use this as a query, open a new query in design view. Close the window that asks what tables the query is to be built on. Open the SQL view of the query design - like design view, but it shows the SQL instead of the normal design interface. Copy the above into the SQL view.
You should now be able to switch to datasheet view and see the results
When the query is working to your satisfaction, save it with any appropriate name
Open a new query in design view
When you get the list of tables to include, switch to the list of queries and include the query you just saved
Change the query type to crosstab and update the query as needed to select rows, columns and values - look up "access crosstab queries" if you need more help.
Another tip to see what is happening here:
You can take the subquery - the parts inside the () above - and make
just that statement into it's own query, excluding the opening and closing (). Then you can look at it's design view to see what it does
Save it with an appropriate name and put it into the query above in place of the statement in () - then you can look at the design view.
Sometimes it's easier to visualize and learn from 2 queries strung together this way than to work with sub queries.

Dynamodb data model for process/transaction monitoring

I am wanting to keep track of multi stage processing job.
Likely just need the following fields
batchId (guid) | eventId (guid) | statusId (int) | timestamp | message (string)
There are relatively small number of events per batch.
I want to be able to easily query events that have a statusId less than n (still being processed or didn't finish processing).
Would using multiple rows for each status change, and querying for latest status be the best approach? I would use global secondary index but StatusId does not seem like a good candidate for hashkey (less than 10 statuses).
Instead of using multiple rows for every status change, if you updated the same event row instead, you could use a technique described in the DynamoDB documentation in the section 'Use a Calculated Value'. Basically this would involve adding another attribute (say 'derivedStatusId') which would be derived by appending a random number to statusId at the time of writing to DynamoDB. For example, for a statusId of 2, derivedStatusId could be one of {"2-00", "2-01", .. "2-99"}. Setting up a Global Secondary Index on derivedStatusId would give you some fan-out that will help in preventing the index from becoming hot.
If you are sure that you will use this index for only unfinished events, then removing the derivedStatusId attribute from the record when it transitions to a finished status will remove it from index as well - which may be a good property if events are expected to finish processing eventually, and if they stay around forever. This technique is called "Sparse Index" and is described in more detail here.
From your question, it seems like keeping status history recording is a desired property (I assume this because you want to have multiple rows for status changes). Consider putting this historical information in the same row. DynamoDB supports list data types and also has a generous 400KB item limit which may just allow you to capture all the desired historical information in the same record.

Amazon MWS API, listing seller's products that is updated after a specific date

I am trying to list the products of a seller (using marketplaceID) that is created or updated after a specific date.
I tried RequestReport with ReportType "_GET_MERCHANT_LISTINGS_DATA_" and setting StartDate to the target date but the data returned contains products that are created (or lastly updated) before that date.
https://developer.amazonservices.com/
The documentation is not very specific on what 'StartDate' actually does:
Start of a date range used for selecting the data to report.
Type: xs:datetime
Default: Now
If I recall correctly, this date does not relate to a products modification timestamps but to a products existance in the database. As an example, setting StartDate to yesterday should give you a list of products that were in the database within the last 24 hours. This includes products that were recently created and products that were created way before that but still exist.
I don't think it is possible to get a list of products that were modified within a timeframe (again, I'm writing this from my recollection on how this worked when I played with it)

Use MapReduce or other distributed computation method for an analytics calculation?

Let's say I have three basic models: a User, a Company, and a Visit. Every time a User goes to a Company, a Visit is recorded in this format (user_id, company_id, visit_date).
I'd like to be able to calculate the average time between visits for a company. Not visits overall, but specifically how long on average one of their customers waits before returning to the store.
For example, if one user visited on Tuesday, Wednesday, and Friday that gives one "gap" of one day, and one "gap" of two days => (1, 2). If another user visited on Monday and Friday, that gives one gap of 4 days => (4). If a third user visited only once, he should not be considered. The average time between user visits for the company is (1 + 2 + 4) / 3 = 2.333 days.
If I have thousands of users, taps, and companies and I want to calculate a single figure for each company, how should I go about this? I've only done basic MapReduce applications before and I can't figure out what my Map and Reduce steps would be to get this done. Can anyone help me figure out a MapReduce in pseudocode? Or is there some other method of distributed calculation I can reasonably perform? For the record, I'd like to perform this operation on my database every night.
The overly simplistic approach would be to have two job steps.
First job step has a mapper to write key values in the form "company:user" and "visit_date". In the example above, the mapper would write something like:
"user1:companyA" -> "2012/07/16"
"user1:comapnyA" -> "2012/07/17"
"user1:comapnyA" -> "2012/07/19"
"user2:comapnyA" -> "2012/07/15"
"user2:comapnyA" -> "2012/07/19"
...
This means that each call to the reducer will pass all of the visits by a single user to a single company. That means that one call to the reducer will pass in:
"user1:companyA" -> {2012/07/16, 2012/07/17, 2012/07/19}
and another call will pass in:
"user2:companyA" -> {2012/07/15, 2012/07/19}
I'm assuming the set of dates (passed in as an Iterable value) is easily managed as you sort it, figure out the gaps and write a record for each gap as a key value pair in the form "company" and "gap". For example, when passed:
"user1:companyA" -> {2012/07/16, 2012/07/17, 2012/07/19}
The first job's reducer will write to the context:
"companyA" -> 1
"compnayA" -> 2
The second job has a pass-through mapper that just passes the company/gap info on to the reducer. Each call to the reducer gives an Iterable value of gaps for a specific company. Iterate through the data to produce an average and write the key value pair in the form "company" and "average_gap".
If the original set of visits gets too big, we can talk about getting hadoop to do the sorting for you with some custom comparators.

Resources