Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

Commit

Permalink
feat: add 商品销量追踪
Browse files Browse the repository at this point in the history
  • Loading branch information
XuCcc committed Mar 20, 2019
1 parent bdfa2b7 commit 60141bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions DuTracker/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ class PriceItem(scrapy.Item):
size = scrapy.Field()
formatSize = scrapy.Field()
price = scrapy.Field()
soldNum=scrapy.Field()
3 changes: 2 additions & 1 deletion DuTracker/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def process_item(self, item, spider):
size = item.get('size')
formatSize = item.get('formatSize')
price = item.get('price')
points = gen_points(brandId, btitle, pid, title, size, formatSize, price)
soldNum = item.get('soldNum')
points = gen_points(brandId, btitle, pid, title, size, formatSize, price, soldNum)
try:
result = influxdb.write_points(points)
except Exception as e:
Expand Down
5 changes: 3 additions & 2 deletions DuTracker/tsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
influxdb = InfluxDBClient(_host, _port, _username, _password, _database)


def gen_points(brandId, btitle, productId, title, size, formatSize, price):
def gen_points(brandId, btitle, productId, title, size, formatSize, price, soldNum):
return [{
'measurement': f"branId_{brandId}",
'tags': {
Expand All @@ -29,6 +29,7 @@ def gen_points(brandId, btitle, productId, title, size, formatSize, price):
'formatSize': formatSize,
},
'fields': {
'price': price
'price': price,
'soldNum': soldNum
}
}]

0 comments on commit 60141bf

Please sign in to comment.