Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Use latest version of all dependecies. Get rid of direct sphere-node-…
Browse files Browse the repository at this point in the history
…connect dependency.
  • Loading branch information
hajoeichler committed Mar 27, 2014
1 parent 3808866 commit 65dbb86
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 39 deletions.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sphere-price-sync",
"description": "Sync your retailer inventory to your SPHERE.IO master project",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/sphereio/sphere-price-sync",
"private": true,
"author": {
Expand Down Expand Up @@ -30,24 +30,24 @@
},
"dependencies": {
"optimist": "0.6.1",
"q": "1.0.0",
"sphere-node-client": "0.3.5",
"sphere-node-connect": "0.4.5",
"sphere-node-sync": "0.4.6",
"q": "1.0.1",
"sphere-node-client": "0.5.2",
"sphere-node-sync": "0.4.12",
"sphere-node-utils": "0.3.3",
"underscore": "1.6.0"
},
"devDependencies": {
"coveralls": "~2.6.1",
"grunt": "~0.4.1",
"grunt-bump": "~0.0.11",
"grunt-coffeelint": "~0.0.7",
"coveralls": "~2.10.0",
"grunt": "~0.4.4",
"grunt-bump": "~0.0.13",
"grunt-coffeelint": "~0.0.8",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.8.2",
"grunt-contrib-coffee": "~0.10.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-shell": "~0.6.2",
"istanbul": "~0.2.3",
"jasmine-node": "~1.13.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-shell": "~0.6.4",
"istanbul": "~0.2.6",
"jasmine-node": "~1.14.2",
"sphere-coffeelint": "git://github.com/sphereio/sphere-coffeelint.git#master"
},
"keywords": []
Expand Down
5 changes: 3 additions & 2 deletions src/coffee/logger.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{Logger} = require 'sphere-node-connect'
{Logger} = require 'sphere-node-utils'
package_json = require '../package.json'

module.exports = class extends Logger

@appName: 'sphere-price-sync'
@appName: package_json.name
14 changes: 7 additions & 7 deletions src/coffee/pricesync.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ = require('underscore')._
_ = require 'underscore'
InventoryUpdater = require('sphere-node-sync').InventoryUpdater
CommonUpdater = require('sphere-node-sync').CommonUpdater
SphereClient = require 'sphere-node-client'
Expand All @@ -10,10 +10,11 @@ class DataIssue
constructor: (msg) ->
@msg = msg

class PriceSync extends CommonUpdater

CHANNEL_ROLES = ['InventorySupply', 'OrderExport', 'OrderImport']
CUSTOMER_GROUP_SALE = 'specialPrice'
CHANNEL_ROLES = ['InventorySupply', 'OrderExport', 'OrderImport']
CUSTOMER_GROUP_SALE = 'specialPrice'

class PriceSync extends CommonUpdater

constructor: (options = {}) ->
super options
Expand All @@ -32,6 +33,7 @@ class PriceSync extends CommonUpdater
@logger = options.baseConfig.logConfig.logger
@retailerProjectKey = options.retailer.project_key

# TODO: move to helper in sphere-node-utils
@inventoryUpdater = new InventoryUpdater masterOpts

@taskQueue = new TaskQueue()
Expand Down Expand Up @@ -89,7 +91,7 @@ class PriceSync extends CommonUpdater
if total? and (page - 1) * perPage > total
deferred.resolve acc
else
client.products.page(page).perPage(perPage).sort("id").fetch()
client.products.page(page).perPage(perPage).sort('id').last('3h').fetch()
.then (payload) ->
processes = _.map payload.results, (elem) ->
processFn(elem)
Expand Down Expand Up @@ -212,15 +214,13 @@ class PriceSync extends CommonUpdater

action = syncAmountOrCreate(@_normalPrice(retailerPrices), @_normalPrice(masterPrices))
if action?
#actions.push action
liveAction = _.clone action
liveAction.staged = false
actions.push liveAction

action = syncAmountOrCreate(@_salesPrice(retailerPrices, retailerCustomerGroupId), @_salesPrice(masterPrices, masterCustomerGroupId), CUSTOMER_GROUP_SALE)

if action?
#actions.push action
liveAction = _.clone action
liveAction.staged = false
actions.push liveAction
Expand Down
8 changes: 5 additions & 3 deletions src/coffee/taskqueue.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Q = require 'q'
_ = require('underscore')._
_ = require 'underscore'

class TaskQueue
constructor: ->
Expand All @@ -9,14 +9,16 @@ class TaskQueue
addTask: (taskFun) ->
d = Q.defer()

@_queue.push {taskFun: taskFun, defer: d}
@_queue.push
taskFun: taskFun
defer: d
@_maybeExecute()

d.promise

_maybeExecute: ->
if not @_active and @_queue.length > 0
@_startTasks @_queue.pop()
@_startTasks @_queue.shift()

_startTasks: (task) ->
@_active = true
Expand Down
21 changes: 8 additions & 13 deletions src/spec/integration.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,20 @@ describe '#run', ->
@unique = new Date().getTime()

delProducts = (id, version) =>
deferred = Q.defer()
data =
actions: [
{ action: 'unpublish' }
]
version: version
@client.products.byId(id).save(data).then (result) =>
@rest.DELETE "/products/#{id}?version=#{result.version}", (error, response, body) ->
if error
deferred.reject error
else
if response.statusCode is 200
deferred.resolve body
else
deferred.reject body
.fail (error) ->
console.log error
done(error)
deferred.promise
@client.products.byId(id).delete(result.version)
.fail (err) =>
if err.statusCode is 400
# delete also already unpublished products
@client.products.byId(id).delete(version)
else
console.error err
done err

@priceSync.masterClient.products.perPage(0).fetch()
.then (products) ->
Expand Down

0 comments on commit 65dbb86

Please sign in to comment.