Geolocation SOQL query - geolocation

I am trying to write a simple trigger on the case object to find the closest account to a given zip code. For simplicity I'll provide only the lines which are causing the error.
//This is a custom object which has all US zip codes with lat and lng info
ZipCodeGeolocation__c zipGl = [SELECT GeoLoc__Latitude__s, GeoLoc__Longitude__s
FROM ZipCodeGeolocation__c
WHERE Name = :c.Zip_Code__c
LIMIT 1];
List<Account> nearCenters = new List<Account>([SELECT Name, Email__c
FROM Account
WHERE DISTANCE (BillingAddress, GEOLOCATION( :zipGl.GeoLoc__Latitude__s, :zipGl.GeoLoc__Longitude__s), 'mi' ) < 50
ORDER BY DISTANCE (BillingAddress, GEOLOCATION( :zipGl.GeoLoc__Latitude__s, :zipGl.GeoLoc__Longitude__s), 'mi' )]);
Every time I add the "ORDER BY" clause, I get the following error:
"An unexpected error occurred. Please include this ErrorId if you contact support: 1398691353-5783 (-929716091)"
Obviously the Error Id is different every time. Has anyone seen this behavior before and what can I do to solve this issue?
Thank you

Related

Output value from getAmountsIn > swapExactTokensForTokens in arbitrage price difference opportunity

Hello,
For a given pair in a flashloan arbitrage operation, taking the example of uniswap and sushiswap as the selected DEX´s for executing an arbitrage opportunity, and for 1INCH/WETH token pair, sushiswap WETH price is cheaper than uniswap (despite having larger reserve volumes in comparison).
The problem lies when I execute the following two lines of code in my `uniswapV2call `method:
uint amountToRepay = UniswapV2Library.getAmountsIn(factory, _amount, path)[0];
uint amountReceived = router.swapExactTokensForTokens(
_amount,
amountToRepay,
path,
msg.sender,
(block.timestamp + 300))[1];
and it returns **amountToRepay > amountReceived** when I was expecting the result to be other way round owing to spotted price difference opportunity under arbitrage operation.
**Output console.log (from my back-end smart contract)**
_getAmountsIn() results.......
path[0] 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
path[1] 0x111111111117dc0aa78b770fa6a738034120c302
amountBorrowed 2497817866881194385864
**amountToRepay 964334905750628563**
getAmountsOut() results.......
path[0] 0x111111111117dc0aa78b770fa6a738034120c302
path[1] 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
**amountReceived 950114205093874394**_
**Output error message**
Error: VM Exception while processing transaction: **reverted with reason string 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'**
at <UnrecognizedContract>.<unknown> (0x7a250d5630b4cf539739df2c5dacb4c659f2488d)
at FlashloanerArbitrage.uniswapV2Call (contracts/FlashloanerArbitrage.sol:261)
at <UnrecognizedContract>.<unknown> (0x86f518368e0d49d5916e2bd9eb162e9952b7b04d)
at FlashloanerArbitrage.startSwap (contracts/FlashloanerArbitrage.sol:180)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at EthModule._estimateGasAction (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\modules\eth.ts:429:7)
at HardhatNetworkProvider._sendWithLogging (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:139:22)
at HardhatNetworkProvider.request (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:116:18)
at JsonRpcHandler._handleRequest (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:188:20)
at JsonRpcHandler._handleSingleRequest (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:167:17)
at Server.JsonRpcHandler.handleHttp (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:52:21)
Where am I going wrong here as this issue has been troubling me for several weeks now.
I have tried implementing other_ pricing oracle methods but it comes back to this very same issue.
Any help or suggestions would be greatly appreciated.
Thank you
Expected the output value from getAmountsIn to be less returned value from getAmountsOut in a spotted arbitrage price difference opportunity.

Need to remove numbers with a javascript code step in Zapier

I am not a developer but have used Google search and trial and error test scenarios with Zapier for the last few days and have given up on figuring this out myself. I need help!
I'm using the Run JavaScript code step in Zapier and provided the following details to Input Data.
It says: What input data should we provide to your code (as strings) via an object set to a variable named inputData?
I'm using "street" with a street address example "1402 Spring Garden Rd"
What is the code to use that regardless of the street address provided all the numbers and first space are removed so that the results is "Spring Garden Rd"
Thank you in advance!
var street = inputData;
var streetNoNumbers = inputData.replace(/[0-9]/g, '');
return streetNoNumbers
The error message I'm getting is
TypeError: inputData.replace is not a function
I've learned that strings are immutable and a new string can be made from manipulating another string but doing this in zapier seems to require a function and creating another var with the calculation generates a ... is not a function.
I've tried to write a function but can't get the output or return to show the proper results either.
I can do the following successfully,
var street = inputData
return street
1402 Spring Garden Road
I want to include the code that manipulates street to produce the following:
Spring Garden Road
David here, from the Zapier Platform team. Great question!
The key understanding you're missing is that inputData is a js object with a street property. Before your code is run, we set it up like so:
const inputData = {street: '1402 Spring Garden Rd'}
Since inputData is an object, it doesn't have a replace method (the error you're seeing). Instead, perform your operation on .street and return that.
Try the following:
// need to return an object, not just a string
return {streetNoNumbers: inputData.replace(/[0-9]/g, '')}
If you want to learn more, I recommend our simple examples: https://zapier.com/help/code/#simple-email-extraction

getAdGroupBidLandscape returning no campaigns found

I'm trying to use the Google AdWords bid simulator system to try and get some insights out of the AdWords bid simulator. More specifically I'm using the AdGroupBidLandscape() functionality, but it's returning 'No Campaigns Found', but we definitely have campaigns where the Bid Simulator tool works through the AdWords web page interface, so I'm a bit confused. Here is the code I'm running, and yes I know I'm only retrieving a single field - I'm just trying to keep things as simple as possible.
from googleads import adwords
import logging
import time
CHUNK_SIZE = 16 * 1024
PAGE_SIZE = 100
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
adwords_client = adwords.AdWordsClient.LoadFromStorage()
dataService = adwords_client.GetService('DataService', version='v201710')
offset = 0
selector = {'fields':['Bid'], #'impressions', 'promotedImpressions', 'requiredBudget', 'bidModifier', 'totalLocalImpressions', 'totalLocalClicks', 'totalLocalCost', 'totalLocalPromotedImpressions'],
'paging': {
'startIndex': str(offset),
'numberResults': str(PAGE_SIZE)
}
}
more_pages = True
while more_pages:
page = dataService.getAdGroupBidLandscape(selector)
# Display results.
if 'entries' in page:
for campaign in page['entries']:
print ('Campaign with id "%s", name "%s", and status "%s" was '
'found.' % (campaign['id'], campaign['name'],
campaign['status']))
else:
print 'No campaigns were found.'
offset += PAGE_SIZE
selector['paging']['startIndex'] = str(offset)
more_pages = offset < int(page['totalNumEntries'])
time.sleep(1)
We have several different accounts attachd to AdWords. My account is the only one that has developer API access, so I sort of wonder if the problem is that my account isn't the primary account associated with the campaigns- I just have one of the few administrator accounts. Can anyone provide some insights about this for me?
Thanks,
Brad
The solution I found to this problem was to add a predicate to the selector specifying a particular CampaignId. While that doesn't make any sense to me that it would fix it, because it should really just be filtering the data with that if I understand things correctly, it seems to have. I don't have a good explanation for that, but I thought someone else might find this useful. If I come to realize this wasn't the fix to the problem I had, I will come back and update this answer.

Cannot to get twitter data in specific location

I try to get American tweets using Twitter4J, when I set the specific location like this code:
FilterQuery fq = new FilterQuery();
double lat1 = 48.996059d;
double long1 = -125.361695d;
double lat2 = 29.269125d;
double long2 = -67.683473d;
twitterStream.addListener(listener);
double[][] bb = {{lat1, long1}, {lat2, long2}};
fq.locations(bb);
twitterStream.filter(fq);
I got error like this:
Parameter not accepted with the role. 406:Returned by the Search API when an invalid format is specified in the request.
Returned by the Streaming API when one or more of the parameters are not suitable for the resource. The track parameter, for example, would throw this error if:
The track keyword is too long or too short.
The bounding box specified is invalid.
No predicates defined for filtered resource, for example, neither track nor follow parameter defined.
Follow userid cannot be read.
Latitude/longitude are not valid: 49.00, -125.36, 29.27, -67.68
I guess Twitter4J cannot read minus(-) coordinate, because when I set without minus, it works.
Thank you for any reply
I solve it by self. It must SW first

QBFC Billadd GUID Error

I am new to C# and QBFC13 code and I'm trying to add a bill from code I found on the intuit developer site under the BillAdd section.
The BillAddRq.ExternalGUID.SetValue(Guid.NewGuid().ToString()); is throwing a error:
Invalid GUID format. Must use zero for Custom Fields, or a GUID generated with GuidGen.exe for private data extensions.
I’ve tried:
String guid = System.Guid.NewGuid().ToString("B");
// MessageBox to see that it creates the number
MessageBox.Show("guid", guid);
BillAddRq.ExternalGUID.SetValue(guid);
BillAddRq.ExternalGUID.SetValue(Guid.NewGuid().ToString("B"));
And
String guid = System.Guid.NewGuid().ToString("0");
And those throw:
QB Test 8-14-2014.vshost.exe - No Disk "There is no disk in the drive. Please insert a disk into drive F."
How can I resolve these errors?
Using your first string attempt is the correct format for the GUID. I tested using GUID.NewGuid().ToString("B") and was able to get a GUID that works when adding a bill.
Because you're getting an error about there being no disk in the drive, it sounds like something else is causing the error. I would step through the code and find the exact place that causes the error as it probably has nothing to do with the GUID.
Here's a simple example that I did using a sample file in QuickBooks:
QBSessionManager SessionManager = new QBSessionManager();
SessionManager.OpenConnection2("GUIDTest","GUIDTest", ENConnectionType.ctLocalQBD);
SessionManager.BeginSession("", ENOpenMode.omDontCare);
IMsgSetRequest MsgRequest = sessionManager.CreateMsgSetRequest("US", 13, 0);
MsgRequest.Attributes.OnError = ENRqOnError.roeContinue;
IBillAdd add = MsgRequest.AppendBillAddRq();
add.ExternalGUID.SetValue(System.Guid.NewGuid().ToString("B"));
add.VendorRef.FullName.SetValue("A Cheung Limited");
add.TxnDate.SetValue(DateTime.Today);
IExpenseLineAdd line = add.ExpenseLineAddList.Append();
line.AccountRef.FullName.SetValue("Travel & Lodging");
line.Amount.SetValue(100.00);
IResponse response = sessionManager.DoRequests(MsgRequest).ResponseList.GetAt(0);
MessageBox.Show(response.StatusMessage);

Resources